hogdriver53
Registered User.
- Local time
- Today, 05:16
- Joined
- Jan 1, 2020
- Messages
- 21
[SOLVED]Single and double quotes
Hi all,
I've searched high and low all over the Net, but am getting stumped .... And I think the culprit is/are the quotation marks. I've downloaded and modified a code I found on the net and it works to a point ....
I use Access 2016.
I have a db, where I would like to open and populate a form (frmWorksheet) with a record that is displayed on a report (rptMDEMexams), which itself is based on a query (qryMDEMexams), which is based on a table (tblMDEMexams). I know it seems over the top, but being a newb this makes is easiest for me to keep it sane
I have a 'Print' button on the report (each line has it's own print button) and when I press the button, it opens the 'Worksheet' form, but pre-populates it with the first record from the table.
Based on the searching and reading I've done is that it all comes down to the quotation marks.
As per my code below, the first double quote is fine but the single quote and double quotes after ... Me![txtContainerNumber]... appear to be the culprits. The single/double quotes turn green, which to me means it's an info line and not used/displayed (as in "blocked" DoCmd at the top of the code).
---------------------------------------
---------------------------------------------
No matter what I try and the order of quotes and single/double quotes, I can't get it to work, and I get the same result.
What am I doing wrong? It's driving me crazy ....
Hi all,
I've searched high and low all over the Net, but am getting stumped .... And I think the culprit is/are the quotation marks. I've downloaded and modified a code I found on the net and it works to a point ....
I use Access 2016.
I have a db, where I would like to open and populate a form (frmWorksheet) with a record that is displayed on a report (rptMDEMexams), which itself is based on a query (qryMDEMexams), which is based on a table (tblMDEMexams). I know it seems over the top, but being a newb this makes is easiest for me to keep it sane
I have a 'Print' button on the report (each line has it's own print button) and when I press the button, it opens the 'Worksheet' form, but pre-populates it with the first record from the table.
Based on the searching and reading I've done is that it all comes down to the quotation marks.
As per my code below, the first double quote is fine but the single quote and double quotes after ... Me![txtContainerNumber]... appear to be the culprits. The single/double quotes turn green, which to me means it's an info line and not used/displayed (as in "blocked" DoCmd at the top of the code).
---------------------------------------
Code:
Private Sub cmdPrint_Click()
'DoCmd.OpenForm "frmRecord", , acNormal, , "FIELD = " & Me!FIELD
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmWorksheet"
stLinkCriteria = "[txtContainerN]= '" & "Me![txtContainerNumber] " [B][COLOR="Red"]'"[/COLOR][/B]
DoCmd.OpenForm stDocName, , stLinkCriteria
End Sub
No matter what I try and the order of quotes and single/double quotes, I can't get it to work, and I get the same result.
What am I doing wrong? It's driving me crazy ....
Last edited: