data in forms from tables with relationships?

stuartam

Registered User.
Local time
Today, 08:08
Joined
Jul 16, 2004
Messages
93
this is a bit hard to explain so i'll start with the basics:

Table structure:

Main table
packref
sessionid
category
( and so on )

history table
IDNUM ( auto number )
packref
state
( and so on )

the main table has a relationship to the history table of 'one to many' on the packref field.

i have a form that calls the data from the main table, but i cant work out how to get it to get the newest bit of history data for the pack ( ie the history that was added last for that pack )

can anyone help, im guessing im just overlooking the obvious ( as usuall )
 
I'm not very experienced myself, but this works if you put it in the Open event of the form. I think it takes a little more coding if you want to go to the latest record in a subform. Let me know, and I will look at it again.


Code:
Private Sub Form_Open(Cancel As Integer)
    DoCmd.GoToRecord acDataForm, "YourFormName", acLast
End Sub
 
I think this will work if you want to go to the last record in a subform. Else use the first example above.

Put this in the main form, to set the focus on the subform:

Code:
Private Sub Form_Open(Cancel As Integer)
      Me.YourSubformName.SetFocus
End Sub

Put this in the subform, to go to the last record:


Code:
Private Sub Form_GotFocus()
    DoCmd.GoToRecord acDataForm, "YourSubformName", acLast
End Sub

I pretty sure it will be okay to put the subform coding in the GotFocus event of the subform. Try it.

Pierre Rousseau.
 

Users who are viewing this thread

Back
Top Bottom