Open form with Command button Error

R

Robin

Hi All,
Using Access 2007. Here's the code i have for the on_click event of a
comand button:

Private Sub OpenCustomer_Click()
On Error GoTo Err_OpenCustomer_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ManageCustomers"

stLinkCriteria = "[AccountNumber]=" & Me![AccountNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenCustomer_Click:
Exit Sub

Err_OpenCustomer_Click:
MsgBox Err.Description
Resume Exit_OpenCustomer_Click

End Sub

When i click the button i get the "Enter Paramater Value" box with the
account number in question shown on the banner of the input box!!! Why is
the AccountNumber not being carried to the 'ManageCustomers' form?

It's also worth mentioning that i tried to create the event using the
command button wizard, however the field list for one of the forms was empty
when i got to the point of linking the fields (in this case AccountNumber)
together so therefore decided to create the code manually.

Thanks for any help
Rgds
Robin
 
M

Marshall Barton

Robin said:
Using Access 2007. Here's the code i have for the on_click event of a
comand button:

Private Sub OpenCustomer_Click()
On Error GoTo Err_OpenCustomer_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ManageCustomers"

stLinkCriteria = "[AccountNumber]=" & Me![AccountNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenCustomer_Click:
Exit Sub

Err_OpenCustomer_Click:
MsgBox Err.Description
Resume Exit_OpenCustomer_Click

End Sub

When i click the button i get the "Enter Paramater Value" box with the
account number in question shown on the banner of the input box!!! Why is
the AccountNumber not being carried to the 'ManageCustomers' form?

It's also worth mentioning that i tried to create the event using the
command button wizard, however the field list for one of the forms was empty
when i got to the point of linking the fields (in this case AccountNumber)
together so therefore decided to create the code manually.


If the AccountNumber field is a Text field, then you need to
use quotes around the value:

stLinkCriteria = "AccountNumber='" & Me!AccountNumber & "' "
 
R

Robin

Thanks V much, problem solved ;-)

Don't suppose you ahve any idea why the wizard wasn't functioning?

Marshall Barton said:
Robin said:
Using Access 2007. Here's the code i have for the on_click event of a
comand button:

Private Sub OpenCustomer_Click()
On Error GoTo Err_OpenCustomer_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ManageCustomers"

stLinkCriteria = "[AccountNumber]=" & Me![AccountNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenCustomer_Click:
Exit Sub

Err_OpenCustomer_Click:
MsgBox Err.Description
Resume Exit_OpenCustomer_Click

End Sub

When i click the button i get the "Enter Paramater Value" box with the
account number in question shown on the banner of the input box!!! Why is
the AccountNumber not being carried to the 'ManageCustomers' form?

It's also worth mentioning that i tried to create the event using the
command button wizard, however the field list for one of the forms was empty
when i got to the point of linking the fields (in this case AccountNumber)
together so therefore decided to create the code manually.


If the AccountNumber field is a Text field, then you need to
use quotes around the value:

stLinkCriteria = "AccountNumber='" & Me!AccountNumber & "' "
 
M

Marshall Barton

You're welcome.

No idea about how most wizards do what they do/don't do. I
haven't used a wizard in years, mostly because it's easier
to get what I want if a wizard is not getting in the way,
but partially because of issues like you asked.
--
Marsh
MVP [MS Access]

Thanks V much, problem solved ;-)

Don't suppose you ahve any idea why the wizard wasn't functioning?

Marshall Barton said:
Robin said:
Using Access 2007. Here's the code i have for the on_click event of a
comand button:

Private Sub OpenCustomer_Click()
On Error GoTo Err_OpenCustomer_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ManageCustomers"

stLinkCriteria = "[AccountNumber]=" & Me![AccountNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenCustomer_Click:
Exit Sub

Err_OpenCustomer_Click:
MsgBox Err.Description
Resume Exit_OpenCustomer_Click

End Sub

When i click the button i get the "Enter Paramater Value" box with the
account number in question shown on the banner of the input box!!! Why is
the AccountNumber not being carried to the 'ManageCustomers' form?

It's also worth mentioning that i tried to create the event using the
command button wizard, however the field list for one of the forms was empty
when i got to the point of linking the fields (in this case AccountNumber)
together so therefore decided to create the code manually.


If the AccountNumber field is a Text field, then you need to
use quotes around the value:

stLinkCriteria = "AccountNumber='" & Me!AccountNumber & "' "
 

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

Similar Threads


Top