Help With Sub Form Refresh

spike250

Registered User.
Local time
Today, 02:39
Joined
Aug 6, 2009
Messages
70
Hi,

I have a sub form that show the last record added - this gets its data from a column in my table. There is code behind the on Timer function to make the box blink.

The problem I have is that on the main form I have put the sub form to show the last record but when the user clicks on Add New Record button i created I cannot get it to refresh the sub form it will only refresh when the user exits the main form and goes back in.

Is there any way to refresh the sub form when a new record is added.

Any help would be appreciated as I am new to Access.

Regards


Spike
:confused::confused::confused:
 
Hi,

Do I use Me.Requery in the sub form or on the main form in the Button to add the new record like.

"Me.Requery ZSubform"

Regards

Spike
:confused::confused::confused:
 
"Me.Requery ZSubform"

That would be the wrong syntax, try this:

Code:
Me!ZSubform.Form.Requery

I assume that the subformconteiner is called ZSubform

JR
 
Hi thanks for the reply.

I have tried to put the following code behind the Main Form under the timer event;
Me!subfrmZNumber.Form.Requery
It keeps refreshing the subform but when you add a new note it put a blank value in the sub form.

Also

I have tried to put the following code behind the sub form itself under the timer event;
Me!subfrmZNumber.Form.Requery
And nothing happens.

Any further help would be great.

Spike
:confused::confused::confused:
 
I have tried to put the following code behind the Main Form under the timer event;
Me!subfrmZNumber.Form.Requery

Why don't you put it behind the AddNew Record button insted?

I have tried to put the following code behind the sub form itself under the timer event;
Me!subfrmZNumber.Form.Requery
And nothing happens.

The syntax for the subform itself would be : Me.Requery, but why put it there??

JR
 
Hi All,

I have copied the code behind my button including the refresh code for the sub form I am not sure it it is in the right place because I cannot get tit to work, when I click on Add New Record Button it creates a blank record like before but the sub form goes blank.

I have also posted the code behind the sub form on the Timer Event.

Add New Record Button
Code:
Private Sub Command39_Click()
On Error GoTo Err_Command39_Click
If userid = "" Then
    MsgBox ("SADLY YOU CANNOT ADD A NEW RECORD AS YOU DIDN'T GIVE A USER ID")
    Exit Sub
End If
Me.AllowAdditions = True
    DoCmd.GoToRecord , , acNewRec
    author = userid
    Me.AllowAdditions = False
Exit_Command39_Click:
    Exit Sub
Err_Command39_Click:
    MsgBox Err.Description
    Resume Exit_Command39_Click
    Me!subfrmZNumber.Form.Requery
End Sub

Sub Form Code

Code:
Private Sub Form_Load()
DoCmd.GoToRecord , , acLast
End Sub

Code:
Private Sub Form_Timer()
If Me.ZNumber.BackColor = 16777215 Then
Me.ZNumber.BackColor = 255
Else
Me.ZNumber.BackColor = 16777215
End If
End Sub

Any further help would be approciated

Spike
:confused::confused::confused:
 
Last edited:
Can anyone tell me if I have put the following in the right place in the Add New Record Button
Me!subfrmZNumber.Form.Requery

Thanks

Spike
 

Users who are viewing this thread

Back
Top Bottom