Finding a record

G

Guest

Hi there
I've created a form called tabular form called recosted jobs.
When the job_code field is clicked I want it to open another form called job
costing and find the corresponding record matching the job code

Here's what i have so far

Private Sub Job_Code_DblClick(Cancel As Integer)
DoCmd.OpenForm "Job Costing", acNormal, "", "", acEdit, acNormal
DoCmd.FindRecord recostedjobs.Job_Code.Value, acEntire, True, ,
True, , True
End Sub

Obviously this works to open the other form, but am having trouble the part
of what to find, ie recostedjobs.Job_Code.Value brings up an object not found
error. Any suggestions.

Thanks
Anthony.
 
N

Nikos Yannacopoulos

Anthony,

DoCmd.OpenForm has a WhereCondition argument that comes in very handy in
situations like yours. Modify your code to something like:

Private Sub Job_Code_DblClick(Cancel As Integer)
cdtn = "[Job_Code_Field] = " & Me.Job_Code
DoCmd.OpenForm "Job Costing", acNormal, "", cdtn, acEdit, acNormal
End Sub

I have made the following naming assumptions:
* field in underlying table of second form called Job_Code_Field
* control on first form called Job_Code
substitute the actual names as appropriate.

Also, I have assumed the Job Code field to be numeric. If it is text,
change the condition expression line to include text delimiters, like:

cdtn = "[Job_Code_Field] = '" & Me.Job_Code & "'"

HTH,
Nikos
 
G

Guest

I've worked it out now, thankyou

Anthony

Nikos Yannacopoulos said:
Anthony,

DoCmd.OpenForm has a WhereCondition argument that comes in very handy in
situations like yours. Modify your code to something like:

Private Sub Job_Code_DblClick(Cancel As Integer)
cdtn = "[Job_Code_Field] = " & Me.Job_Code
DoCmd.OpenForm "Job Costing", acNormal, "", cdtn, acEdit, acNormal
End Sub

I have made the following naming assumptions:
* field in underlying table of second form called Job_Code_Field
* control on first form called Job_Code
substitute the actual names as appropriate.

Also, I have assumed the Job Code field to be numeric. If it is text,
change the condition expression line to include text delimiters, like:

cdtn = "[Job_Code_Field] = '" & Me.Job_Code & "'"

HTH,
Nikos
Hi there
I've created a form called tabular form called recosted jobs.
When the job_code field is clicked I want it to open another form called job
costing and find the corresponding record matching the job code

Here's what i have so far

Private Sub Job_Code_DblClick(Cancel As Integer)
DoCmd.OpenForm "Job Costing", acNormal, "", "", acEdit, acNormal
DoCmd.FindRecord recostedjobs.Job_Code.Value, acEntire, True, ,
True, , True
End Sub

Obviously this works to open the other form, but am having trouble the part
of what to find, ie recostedjobs.Job_Code.Value brings up an object not found
error. Any suggestions.

Thanks
Anthony.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top