Use two Criteria on open event

L'apprentis

Redcifer
Local time
Yesterday, 17:13
Joined
Jun 22, 2005
Messages
177
Hello, I am trying to find a way to open a form with a subform on a specific record (for the form and the subform), I came up with the following but keep getting a mismatch mistake which means me think I am not doing it right.
What would be the apropriate way to achieve what I am trying to do?

Code:
Dim stDocName As String

    'To Link to 1) Drawing File ID on main form
    Dim stLinkCriteria As String

    'To Link to 2) Drawing ID on subform
    Dim StLinkCriteria2 As String

    stDocName = "FrmDrawingDetail"
    
   stLinkCriteria = "[DrawingFileID]=" & Me![DrawingFileID]
   StLinkCriteria2 = "Forms!stDocName!SFrmDrawingDetail.Form!TxtDrawingID=" & Me![DrawingID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria And StLinkCriteria2
 
How about:

DoCmd.OpenForm stDocName, , , stLinkCriteria & " And " & StLinkCriteria2
 
Cheers Ken, It's still can't make it work but I get a blank form now.
Do you think that the way I have referenced the txtbox in the subform seems to be correct?
ie: StLinkCriteria2 = "Forms!FrmDrawingDetail!SFrmDrawingDetail.Form!TxtDrawingID=" & Me![DrawingID]
 
Hum...

So you have a form (f1) that opens a second form (f2) which has the subform (sf1)? And when you open f2, you want a specific record to be displayed?
 
Yes, that's exactly it,
I'd like to have a specific record displayed for f2 and sf1
 
Can you use the primary key on f1 as a criteria for the recordsource of f2?
 
I am sorry for the late reply, I had many problem to sort out all at the same time and I though that waiting a bit for that one would help me to find the solution but I am still pretty stuck.
To answer the latest post : If I can use the primary key on form1 as a criteria for to the record source of form2? Well...I don't think so...The primary key of form1 should be used as a criteria to subform2 (contained in form2). I hope that my problem makes sense, I'll gladly give more details if it is needed. Thanks in advance.
 

Users who are viewing this thread

Back
Top Bottom