Refreshing Page

Spiel.1984

New member
Local time
Today, 11:16
Joined
Feb 24, 2010
Messages
5
Hi there,

What I am trying to do is make certain information visible depending on what has been entered already. I have written the following code;
If Me.Type = "MTA" Then
Me.Recipient.Visible = True
Else
Me.Recipient.Visible = False
End If
If Me.Type = "NDA" Then
Me.Partner_Organisation.Visible = True
Else
Me.Partner_Organisation.Visible = False
End If

This does the job, however I cannot make it automatically refresh. I have tried popping macros or writing the code into various different events, but the only way to get the screen to refresh and the correct control to be displayed is to either exit the form and re-enter or to click refresh all. What am I doing wrong? Any help would be greatly appreciated.

Cheers

Neil
 
Stick this code into a sub in the form module first.

Then on the forms OnCurrent Event, the After update Event of the control Me.Type enter

Call YourSubName

BTW you should not have controls/fields named Type this is an Access reserved word and can lead to all sorts of problems

Code:
If Me.Type = "MTA" Then
Me.Recipient.Visible = True
Else
Me.Recipient.Visible = False
End If
If Me.Type = "NDA" Then
Me.Partner_Organisation.Visible = True
Else
Me.Partner_Organisation.Visible = False
End If

More efficient code:

Code:
Select Case Me.Type
   Case "MTA"
       Me.Recipient.Visible = True
   Case "NDA"
       Me.Partner_Organisation.Visible = True
   Case Else
       Me.Recipient.Visible = False
       Me.Partner_Organisation.Visible = False
End Select
 
Genius. Thank you very much. There I was thinking I was beginning to understand Access.

I actually have another problem as well that maybe you might be able to help with. The database I have created has a series of forms all running of individual tables. I would like all of these tables to run off the same reference number which is the autonumber on the main table. I would like to be able to access these forms via buttons making each form accessible no matter what form you are on. I have created this and it all seems to work OK until you create a new record. It is then unable to find the the reference number of the new record I have created. To find the information I have to manually type the reference number and then it can find everything else. Is there a way for the reference number to automatically be update on every table as soon as the record is created?

Sorry if this is a completely garbled messge.

Cheers for any help that you could give.

Cheers

Neil
 
It won't let me upload the file. I guess maybe it's too big. It can be found at the following link though;

<https://www.bris.ac.uk/fluff/u/rewnb/_zxbM13j2nxe1t8OBkc_YQFG/>

Cheers

Neil
 

Users who are viewing this thread

Back
Top Bottom