Opening a form at a record based upon a record in a sub form

Kernel Kev

New member
Local time
Today, 21:30
Joined
Feb 25, 2008
Messages
6
Right guys and girls i have a problem. I have looked at some threads here which talk about this sorta thing but im not too sure if its what i need and to be honest i dont understand it fully.

Here goes...

I have a form which shows jobs for a motorcycle workshop. A subform is created which runs off a query using JobID from the jobs table which is linked to JobID# in the problems table. So, when i am viewing a certain job, i can only navigate to the problems related to that job in the sub form.

I have two buttons in the jobs main form which one opens the problems main form (used to fill in a new problem, as subform dosent have all fields) at a new record, this was easy as the wizard does this no problems.

I have another button which is titled EDIT, at the moment this button opens the problems form at the first record, however this is not what i would like it to do.

I would like the the form to copy the problemID from the sub form, open the problem main form and navigate to the record with that problemID.

I have looked at macros, all the button commands but i cant figure it out.

Im not a complete n00b with code as i have got dynamic combo boxs running from code which i understand, however i have not enough knowledge to be able to figure this one out or interpret other threads similar to get it working with mine.

I hope some nice person can help me here, my database is functioning 100% all i have left is to try to get the above working. If this is possible i would be in so much debt to you guys.



Kev
:cool:
 
If you want the form opened with only the relevant record, you want to use the wherecondition argument of DoCmd.OpenForm.
 
Ok thanks, here is what i just found, is this correct?

DoCmd.OpenForm "Problems", ProblemID=" & Me.ProblemID#

Im pretty sure i got the where conditions wrong, this is the part i need help with i think.

Thanks for the help.



Kev
:cool:
 
Update: i am being an idiot, i just noticed that the button wizard does exactly what i wanted it to do hehehe.

Thanks anyways, i managed to get it working without the wizard then noticed it lol, typical.



Kev
:cool:
 
Well, that's in the wrong position. VBA Help would guide you to the correct syntax, but if memory serves there would be 3 commas. You would also need quotes before ProblemID (you close them after the = but never opened them). Also, if that "#" is part of the name, it might need to be in brackets. Spaces and symbols are bad ideas in object names.
 

Users who are viewing this thread

Back
Top Bottom