Note that that will fail on names that include apostrophes.
To be able to handle those, use
stLinkCriteria = "[Given Name]=""" & Me![Given Name] & """"
(that's three double quotes after the equal sign, and four double quotes
after the final ampersand).
Of course, that will then fail on names that include double quotes
(hopefully that's not a problem.)
If you need to be able to handle both apostrophes and double quotes,
you'll
need to use something like:
stLinkCriteria = "[Given Name]='" & _
Replace(Me![Given Name], "'", "''") & "'"
Exagerated for clarity, that's
stLinkCriteria = "[Given Name]= ' " & _
Replace(Me![Given Name], " ' ", " ' ' ") & " ' "
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Maurice said:
Pierre try this:
Private Sub Open_Target_Folder_pg_2_Click()
stDocName = "Target Folder page 2"
stLinkCriteria = "[Given Name]='" & Me![Given Name] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
Note: after the = sign you place a single quote and a double quote.
After
the last & you place a double quote, a single quote ad a double quote
again...
hth
--
Maurice Ausum
:
Would you be able to look at this and tell me where I went wrong.
After
entering said code. I was given an Run-time error '3075':
Syntax error (missing operator) in guey expression '[Given
Name]=Person
Name'.
I clicked debug and last line "DoCmd.OpenForm........" was
highlighted.
Clicked X and OK to "This command will Stop the debugger."
Entered Code:
Private Sub Open_Target_Folder_pg_2_Click()
stDocName = "Target Folder page 2"
stLinkCriteria = "[Given Name]=" & Me![Given Name]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
:
Hi Pierre
Private Sub ButtonName_Click()
stDocName = "Form2"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
Change ButtonName and ID (to the linking field name). Also Form2 to
the
name of the form you want to open.
Good luck
--
Wayne
Manchester, England.
:
Help Need - I an haveing an issues with my Access form button
code. I
would
like to create a button to open the 2nd page. But it has to open
vewing the
record from the previous page.
Note: I was able to creat a button to open 2nd form with (just
the)
same
record or Open with all records but on the first record view.