Can't get text string to recognize query result

J

J. Keggerlord

Private Sub cmdConfirm_Click()

Dim strMsg As String

If Me.cboApproval = "Approved" Then
strMsg = "Your meeting request has been approved." & (Chr(13))
strMsg = strMsg & "Meeting Date: " & Format([txtFTDate], "mm/dd/yyyy") &
(Chr(13))
strMsg = strMsg & "Meeting Start: " & Format([txtFTStart], "h:mm AMPM") &
(Chr(13))
strMsg = strMsg & "Meeting End: " & Format([txtFTEnd], "h:mm AMPM") &
(Chr(13))
strMsg = strMsg & "Meeting Location: " & [txtFTBldg] & "." & [txtFTRoom] &
(Chr(13))
strMsg = strMsg & "Your Facilitator will be: " &
queries.[qryPersonName].[FirstName] & (Chr(13))
Else
strMsg = "We're sorry, but your meeting request was disapproved for the
following reason: " & (Chr(13)) & [DisapCode] & (Chr(13))
End If

Where my code falls apart is trying to get the value from
"queries.[qryPersonName].[FirstName]" to provide me with a return value. Did
I completely screw up the formatting on this one? The query parameter is
from a combo box on the form, if that makes any difference. The rest of the
code works fine in debug.print mode.
 
J

John W. Vinson

Where my code falls apart is trying to get the value from
"queries.[qryPersonName].[FirstName]" to provide me with a return value. Did
I completely screw up the formatting on this one?

No, just the syntax. You can't refer to the Queries collection in this way.
Try

DLookUp("[FirstName]", "[qryPersonName]", <optional criteria>)

The criteria should be a String value which evaluates to a valid SQL WHERE
clause without the word WHERE if qryPersonName returns multiple records.

John W. Vinson [MVP]
 
J

John W. Vinson

strMsg = "Your meeting request has been approved." & (Chr(13))

Just another suggestion - use the VBA constant vbCrLf instead of Chr(13).
That's JUST a carriage return, you need both a carriage return and a linefeed.

John W. Vinson [MVP]
 

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