Open form with a related record

P

Peter

Form A dn Form B. I want to open form B with related data in Form A. I want
to open Form B from the related record.
 
C

Chegu Tom

I am guessing on what you really want to do. If you want to open form B for the code found in a record in form A. For example 'txtCode' is code field in form A and you want to open form B for records where the code in form B 'BCode' = what was in the txtCode field on form A

Open the doubleclick event for txtCode field in form A

use a command like the following
If BCode is a text field (note the single and double quotes)

docmd.openform "FormB", , , "BCode ='" & me.txtCode & "'"

If BCode is a numeric field

docmd.openform "FormB", , , "BCode =" & me.txtCode


DoubleClick on the txtCode box to open Form B to that record
 
P

Peter

Thank you for you effort Tom, but it does not function...I applied a
commandbutton in the record in Form A..and i want Form B to open with that
specific record...Form a is a continous form that i use only to display all
records...and form B is a singlerecord form...i must be doing something
wrong...Once again...thank you for your time
 
P

Peter

Hi Tom
DoCmd.OpenForm("Single
View",[ViewAsAcFormView=acNormal],,[WhereCondition:"Case ID ="&Me.Case ID])
 
C

Chegu Tom

peter

are you still there. I have been away for the last week

Two things come to mind one I have never seen [WhereCondition:... syntax
before try just "Case ID =" & Me.Case ID

This should work if your caseID is a NUMERIC field. If it is a text field
you will need some single quotes like this

"Case ID ='" & Me.Case ID & "'"

and since your Field Case ID has a space in it (avoid spaces in names use
CaseID or Case_ID) you will need some square brackets

"[Case ID] =" & [me].[case id] or "[Case ID] ='" & [me].[case id] & "'"

If your first form is looking at the same table as the second form (one has
continuous forms and one has single forms) you might get what you want by
switching from datasheet to form view on the second form




Peter said:
Hi Tom
DoCmd.OpenForm("Single
View",[ViewAsAcFormView=acNormal],,[WhereCondition:"Case ID ="&Me.Case
ID])

Chegu Tom said:
Can you paste the onClick routine for that button?
 
P

Peter

Hi Chegue, thanks a lot...your suggestions to a sollution has proven very
helpful. I used Toms and yous ideeas in different part of my humble
application and they work just fine..once again..thanks a lot!

Chegu Tom said:
peter

are you still there. I have been away for the last week

Two things come to mind one I have never seen [WhereCondition:... syntax
before try just "Case ID =" & Me.Case ID

This should work if your caseID is a NUMERIC field. If it is a text field
you will need some single quotes like this

"Case ID ='" & Me.Case ID & "'"

and since your Field Case ID has a space in it (avoid spaces in names use
CaseID or Case_ID) you will need some square brackets

"[Case ID] =" & [me].[case id] or "[Case ID] ='" & [me].[case id] & "'"

If your first form is looking at the same table as the second form (one has
continuous forms and one has single forms) you might get what you want by
switching from datasheet to form view on the second form




Peter said:
Hi Tom
DoCmd.OpenForm("Single
View",[ViewAsAcFormView=acNormal],,[WhereCondition:"Case ID ="&Me.Case
ID])

Chegu Tom said:
Can you paste the onClick routine for that button?



Thank you for you effort Tom, but it does not function...I applied a
commandbutton in the record in Form A..and i want Form B to open with
that
specific record...Form a is a continous form that i use only to display
all
records...and form B is a singlerecord form...i must be doing something
wrong...Once again...thank you for your time

:

I am guessing on what you really want to do. If you want to open form
B
for the code found in a record in form A. For example 'txtCode' is
code
field in form A and you want to open form B for records where the code
in
form B 'BCode' = what was in the txtCode field on form A

Open the doubleclick event for txtCode field in form A

use a command like the following
If BCode is a text field (note the single and double quotes)

docmd.openform "FormB", , , "BCode ='" & me.txtCode & "'"

If BCode is a numeric field

docmd.openform "FormB", , , "BCode =" & me.txtCode


DoubleClick on the txtCode box to open Form B to that record

Form A dn Form B. I want to open form B with related data in Form A.
I
want
to open Form B from the related record
 

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

Top