button on a subform to lookup a record in mainform

Slayboy

Registered User.
Local time
Today, 22:09
Joined
Apr 28, 2004
Messages
28
Basically I want to jump to a record on a mainform by clicking a button on a subform within the mainform:

I have a form which shows records and within each record there are several sub-records, to help me jump straight to a certain sub-record I have put a subform down the side that is linked to the mainform and lists all sub-record numbers for the record that I am currently on. Next to each sub-record number is a button, I want to be able to press this button and it takes me straight to that sub-record on my main form, basically a lookup.

The closest I have got to what I want is to click the button, it then copies the sub-record number to the main form and sets the focus on a button on the mainform that will lookup the sub-record when clicked. So basically I click on the number I want and have to press return to get to it. but I want to just press it and it takes me to the sub-record without having to hit enter as well.

So i've got the code to get the number from the subform to the mainform and the code to lookup the record on the mainform, but i can't do the whole thing from the subform?

This was really hard to try to explain so if you think you can help me then please ask questions to clarify anything.
 
Any Help?

Someone must have an idea of how to do this, I feel like I am close to working it out but I'm just missing a step.

Any ideas are welcome?
 
Yes I do and if you know how it is actually VERY easy!

1) Make sure to change your code from "Private sub" to "Public Sub"
This way other forms are allowed to call your forms code...

2) In the subform "call" the Parent form like so:
Call Me.Parent.cmdButton

Where cmdButton is the code I want to trigger.

Good luck!
 
So Close!

Ok so I'm trying to do the call but something isn't working:

in my subform I have this code:

Public Sub Command1_Click()
Dim Donna As String
Donna = Me![obs number]
Call LookAdipose
End Sub

and in my main form I have this code:

Public Sub LookAdipose(Doctor)
Me.RecordsetClone.FindFirst "[obs number]='" & Doctor & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub


It says it doesn't recognise the function 'LookAdipose' but I've tried putting the mainform name first: [F06 - Audit Observation SubformA].LookAdipose
But it has a problem with the name?
 
It says it doesn't recognise the function 'LookAdipose' but I've tried putting the mainform name first: [F06 - Audit Observation SubformA].LookAdipose
But it has a problem with the name?

Look closely again at my above sample... now look again at yours... you are missing a crutial part in the Call line....
 

Users who are viewing this thread

Back
Top Bottom