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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd OpenForm issue...

Status
Not open for further replies.

btj

Technical User
Nov 17, 2001
94
US
I had a pop-up form that could be generated from double clicking on a field ("ID") in a subform. The purpose is to display additional pieces of data should the user want to see it.

I am using the following code to do this:
Private Sub txtTcID_DblClick(Cancel As Integer)
DoCmd.OpenForm FormName:="TCdetail", WhereCondition:="tcID='" & Me.txttcID & "'"
End Sub

My problem is that I have developed a need to insert multiple WhereCondition statements as a way to ensure that the user is opening the correct record.

I have tried working with the syntax but am not getting anywhere. Please help me out if you can...I am stuck and need assistance.

Thanks,
Ben
 
Just build your where clause like a SQL statement, eg:

WhereCondition:="tcID='" & Me.txttcID & "' and tcNum = " & Me.txttcNum & "

Good Luck,
Mike T
 
ooops, need a cstr in there (assuming my eg was an integer):

WhereCondition:="tcID='" & Me.txttcID & "' and tcNum = " & Cstr(Me.txttcNum)
 
Mike,
Thanks for the quick post...I will keep your solution in mind. I actually just figured it out.

In case anyone is interested, this is the code I used:
Private Sub txtTcID_DblClick(Cancel As Integer)
Dim strDoc As String
Dim strReq As String

strDoc = "TCdetail"
strReq = "[tcID]= '" & Me.txttcID & "' AND [BuildID] = '" & Me.txtBuildID & "'"

If IsNull(txtBuildID) Then
DoCmd.OpenForm FormName:="TCdetail", WhereCondition:="tcID='" & Me.txttcID & "'"
Exit Sub
Else
DoCmd.OpenForm strDoc, , , strReq
End If

End Sub


Mike, again, thanks for the answer!
 
better still:

Private Sub txtTcID_DblClick(Cancel As Integer)
Dim strDoc As String
Dim strReq As String

strDoc = "TCdetail"
strReq = "[tcID]= '" & Me.txttcID & "'" & _
iif(IsNull(Me.txtBuildID),""," AND [BuildID] = '" & Me.txtBuildID & "'"

DoCmd.OpenForm strDoc, , , strReq

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top