Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I refresh a form

Status
Not open for further replies.

orisons

Programmer
Feb 18, 2002
49
CA
How can I refresh a form after I have updated a data file that contaians some object characteristics (i.e a caption on a command button that has been changed in the data file).
I have came across the form.refresh command but I may be using it incorrectly or in the wrong context.
anyhelp would be much appriciated.
 
The problem is I have a form with various cmd buttons on it which I am making a bit more customisable for the user. this involves opening another form (from a menu) then updating the captions on the buttons, this then opens the .dat file and replaces all of the original captions withthe new ones.
The problem is I cant see the effect immediately on the original form as it still has the old information.

I hope this makes sense if it dosn't just come over and slap me and tell me to make sense.

Thank you
 
its been awhile since I've done some web dev, but try looking into the from.submit without specifing a page to go to. By default it will fall back to itself. Basically refreshing the page from the server. You can do this directly in code without tying it to a cmd btn.

Thanks,
WebGuyToo
 
WebGuyToo: You do realize this is the Visual Basic forum not the Javascript forum? Your answer doesn't make sense in the context of this forum.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
In this example c1,c2,c3 and c4 are commad buttons:

Code:
  Dim f As Integer
  Dim TheCaption As String
  
  f = FreeFile
  
  Open "C:\test.dat" For Input As #f
  
  Input #f, TheCaption
  c1.Caption = TheCaption
  
  Input #f, TheCaption
  c2.Caption = TheCaption

  Input #f, TheCaption
  c3.Caption = TheCaption
  
  Input #f, TheCaption
  c4.Caption = TheCaption
  
  Close (f)


This code should be placed in form_Activate

I assume that u:
1. click the menu
2. the main form is disabled and the other form opens
3. do the caption changes
4. click "ok", to save data to ".dat" file
5. unload the form and
6. last line of code is "form1.enabled = true" !!!!


I mean that by disabling the form and then (after submiting in the other form) enabling again the "form_activate" called.


Ok?
-bclt
 
Thanks I never thought of just closing the form when I open the menu item and re-opening it after the update. One more question though, the form I am using to update the data file with I would like to update the lablels on that too. How i don't know, I'm sure someone will know.....
 
I didn't say to close the form, just when you load the form that saves the data in the dat file (click the menu item); do this:

me.enabled=false
load frmblabla
frmblabla.show

As if it disabled you cannot set focus to the form. As you click ok save the text's in the dat file and then:
unload me 'close the form
from.enabled=true ' As you enable it the event "form_activate is called", so place the code that reads from the dat file in that event handler.

As for the second question of yours, do the same; code to read the dat file in form_activate:

...
Input #f, TheCaption
Label1.Caption = TheCaption
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top