Open a Form and Close other...

G

Guest

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.
 
G

Guest

And what's the code behind the button?

You could use something like:

DoCmd.openform "Yourformname",,,"Where [IDfield]= " & me.[IDfield] -->(from
form 1)

Replace the fieldnames with your own fieldnames...

hth
 
G

Guest

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
 
G

Guest

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

Wayne-I-M said:
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.



Pierre said:
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.
 
G

Guest

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


Pierre said:
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

Wayne-I-M said:
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.



Pierre said:
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.
 
G

Guest

And just to be sure place your formname between brackets like this:

[Target Folder page 2]

The spaces in the formname might be an issue as well.
--
Maurice Ausum


Pierre said:
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

Wayne-I-M said:
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.



Pierre said:
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.
 
D

Douglas J. Steele

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


Pierre said:
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

Wayne-I-M said:
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.
 
G

Guest

I really appreciate your help with this. I tried both ways that you just
stated (name came up missed spelled when [ ] was added). With adding "'" I
was still given the same error code "Run-time '3075':

additional question - I removed part of this code when I used the button
wizard to build it. Should I have left that part on - note: result was still
the same
Removed code:
On Error GoTo Err_Open_Form_page_2_Click -and-

- remaining code is here -

Exit_Open_Form_page_2_Click:
Exit Sub

Err_Open_From_page_2_Click:
MsgBox Err.Description
Resume Exit_Open_Form_page_2_Click

Maurice said:
And just to be sure place your formname between brackets like this:

[Target Folder page 2]

The spaces in the formname might be an issue as well.
--
Maurice Ausum


Pierre said:
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

Wayne-I-M said:
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.
 
G

Guest

if I use the "Replace(Me![Given Name]" code - would it change the name of the
file

Douglas J. Steele said:
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


Pierre said:
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.
 
D

Douglas J. Steele

No.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Pierre said:
if I use the "Replace(Me![Given Name]" code - would it change the name of
the
file

Douglas J. Steele said:
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.
 
G

Guest

I just tried the secound part of your code and its shows up RED (as if its
not complete) Am I missing something.

Code was typed:

Private Sub Open_Target_Folder_pg_2_Click()

stDocName = "Target Folder page 2"
stLinkCriteria= "[Given Name]='" & _
Replace(Me![Given Name], "'", "''") & "'"
DoCmd.OpenForm stDocName, , ,stLinkCriteria

End Sub

Douglas J. Steele said:
No.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Pierre said:
if I use the "Replace(Me![Given Name]" code - would it change the name of
the
file

Douglas J. Steele said:
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], " ' ", " ' ' ") & " ' "


--
 
D

Douglas J. Steele

Other than the fact that you haven't declare stDocName and stLinkCriteria as
string variables, that code looks correct.

One possibility is that your Regional Settings are such that you need to use
a semi-colon (or some other character) rather than comma in the Replace
function.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Pierre said:
I just tried the secound part of your code and its shows up RED (as if its
not complete) Am I missing something.

Code was typed:

Private Sub Open_Target_Folder_pg_2_Click()

stDocName = "Target Folder page 2"
stLinkCriteria= "[Given Name]='" & _
Replace(Me![Given Name], "'", "''") & "'"
DoCmd.OpenForm stDocName, , ,stLinkCriteria

End Sub

Douglas J. Steele said:
No.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Pierre said:
if I use the "Replace(Me![Given Name]" code - would it change the name
of
the
file

:

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], " ' ", " ' ' ") & " ' "


--
 

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