Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I have a form open another form with 2 link criteria

Status
Not open for further replies.

Krash878

Programmer
May 8, 2001
172
0
0
US
I have a form with 2 fields.
One is for a date and the other is for combo box. I have a command button that should open another form with the data from the Original form. Here is my code behind the button.

Dim stDocName As String
Dim stLinkCriteria As String
Dim stLinkCriteria1 As String

stDocName = "frmChargeBackBalanceLookup"

stLinkCriteria = "[CardType]=" & "'" & Me![CardType] & "'"
stLinkCriteria1 = "[rptDate]=" & "#" & Me![DateRpt] & "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria And stLinkCriteria1

With this code I get an Access popup that says Type Mismatch. It only has the OK button so I can not see where I am messing up.

Thanks

Krash
 
I am really new to this but is this right

stLinkCriteria1 = "[rptDate]=" & "#" & Me![DateRpt] & "#"

rptDate and DateRpt

Sorry if I am way off here. I am just getting my head round things and do not feel confident to advise, but it did seem to jump out at me.
 
Krash878:

try
Dim stLinkCriteria1 As Date


regards

agouws

Note to Evotwo:

Any two fields with different descriptions can be linked from form to subform. The data is what matters here.
If the link is created for equal data in different table fields you can have a field named [Field1] in [Table1] on Main Form 1 which is happy to make a match with [Field2] in [Table2]on Sub Form 2

You can use any two criteria names to link fields from main form to subform as long as those field names are on the forms being linked and the data value/format is equal.

regards

agouws
 
Thanks agouws for taking the time to explain that. With the original post (sorry Krash! for my attempt)I can see exactly what you mean. Appreciated!

Cheers
EvoTwo
 
I know this post happened a long time ago, but I recently had the same problem and resolved it after an agravating few hours. Here is what worked for me:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmChargeBackBalanceLookup"

stLinkCriteria = "[CardType]=" & "'" & Me![CardType] & "'"
stLinkCriteria = stLinkCriteria & " AND [rptDate]=" & "#" & Me![DateRpt] & "#"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top