refreshing a form

kwtmd

Registered User.
Local time
Today, 14:42
Joined
May 21, 2004
Messages
46
I have 2 open forms that are connected by a query and not a parent child type relationship. that is the values from fields on first form are used via functions to create a query which is the basis of the second form. I would like it to behave similar to how a subform works, that as it updates the main form, the second form 'refreshes' its view. How do I do this?
 
Use the On Current event on the main form to change the display of related records on the sub form. You can use some code there to requery the subform.
 
I have a simalar problem except my forms are both subforms. what I what is when the user changes to a different record in a datasheet form (which is a subform) and then I have another form which is based on a query at the moment (have tried using a setvalue and onfilter but nothing happens except errors). what am I doing wrong?

Thanks in advance
 
Is there any link between your sub form and main form at all?

Like a form refernce in the query



To requery the main form use,

me.requery


to requery another form use

forms!formname.requery
 
no link

I do not have a link. The only "link" is that the other form is based on a query using functions from the main form. I have tried using the requery and it does not update the form. The only way it seems I get refresh the form is to close it and then reopen it. There must be a better way. The requery and refresh concepts elude me....
 
Requery does work, can you post your code or attach your database
 
Private Sub Form_Current()
intField2 = [ProbNum] 'sets current probnum to a variable - function
Debug.Print "this is ProbNum on current form", intProbNum

Forms![frmPatGoalTx].Requery
End Sub


the form name is frmPatGoalTx. It is already open.

when I use the above code, it returns an error.... can't find the form....
 
Thanks SQL_Hell,

I am getting the same error (see attachment)

here is the code I am using:

Private Sub Form_Current()
Forms!frm_Record_selected_FormView.Requery
End Sub


Thanks alot for helping
 

Attachments

  • can't_find_error.gif
    can't_find_error.gif
    6.4 KB · Views: 177
I thought it was a subform you were Requerying in which case your syntax is incorrect, use the Code builder again ;)
 
Rich said:
I thought it was a subform you were Requerying in which case your syntax is incorrect, use the Code builder again ;)

a subform is requering another subform. it is just my inexperiance with VBA.
how do i use a expresion builder in VBA? :confused: That I would like to see. :)
 
Last edited:
in older versions you can't, so use the conditions part of a macro and paste it. Remember not to save the macro though
 
I have Office XP. How do you get the expression builder for that in VBA for Office XP?
 
Hi guys

kwtmd have you got yours working yet?

I just tried to use the "GoToControl" action before the requery action in the macro but that does not work either. :( I think it may have something to do with the reference to the form name. here is the code in the control name box:

Code:
Forms![frm_Book_Entry_form]![frm_Record_selected_FormView].[form]![Title]

What I am doing is selecting the form so that the subform (form view) has the selection boxes around it, then go into the properties>>all and then I Copy the whats in the name box, then I go to the macro and paste it in the right part of the code in the macro.

Is this the wrong thing to do?

Can someone please reply?
 
Last edited:
Hi all

Just got it working (about time too!!)

kwtmd here is what I did:
In Visual basic:

Code:
Private Sub Form_Current()
Forms!frm_Book_Entry_form!frm_Record_selected_FormView.Requery
End Sub

This contains no spaces (this forum will put the spaces in)

Hope this helps!!

Thanks all you smart people. You have been a BIG help
 
Last edited:

Users who are viewing this thread

Back
Top Bottom