Enter Parameter Value

S

Simon Harris

Hi All,

I am using the following code to open up a form following the user double
clicking on an item in a listbox...

Private Sub ListBoxCustomers_DblClick(Cancel As Integer)
'Open selected customer for editing
stDocName = "frmAddEditCustomers"
MsgBox (Forms!frmCustomers!ListBoxCustomers) 'Diags - Returns expected
value
stLinkCriteria = "[id]=" & Forms!frmCustomers!ListBoxCustomers
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

When the form opens, I get a dialogue box that says "Enter Paramter Value".
If I enter a known record ID, I get the expected record.

Can someone please advise what I need to change in then opening form to
accept the criteria and open the required record, without having to type it
into the "Enter Parameter Value" box?

Many Thanks!

Simon.
 
D

Douglas J Steele

Does the message box display the correct value? From the naming convention,
I'm assuming that ListBoxCustomers is a list box. Is it set to MultiSelect?

Does the Enter Parameter Value dialog list any part of
Forms!frmCustomers!ListBoxCustomers on it?

What's the data type of ID: numeric or text?

If it's text, try:

stLinkCriteria = "[id]=" & Chr$(34) & Forms!frmCustomers!ListBoxCustomers &
Chr$(34)
 
S

Simon Harris

Hi Douglas,

Thanks for your post - Answers below...

Douglas J Steele said:
Does the message box display the correct value? From the naming
convention, Yes

I'm assuming that ListBoxCustomers is a list box. Is it set to
MultiSelect?
MultiSelect is set to 'None'
Does the Enter Parameter Value dialog list any part of
Forms!frmCustomers!ListBoxCustomers on it?
No, the title of the box is 'Enter Parameter Value' it then says ID with a
text input field and an OK button
What's the data type of ID: numeric or text?
Numeric


Do I need to do anything on the opening form to make it accept the incoming
variable/criteria? I created the form using the Wizard initially, and then
changed the layout.

Many Thanks,
Simon.

If it's text, try:

stLinkCriteria = "[id]=" & Chr$(34) & Forms!frmCustomers!ListBoxCustomers
&
Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Simon Harris said:
Hi All,

I am using the following code to open up a form following the user double
clicking on an item in a listbox...

Private Sub ListBoxCustomers_DblClick(Cancel As Integer)
'Open selected customer for editing
stDocName = "frmAddEditCustomers"
MsgBox (Forms!frmCustomers!ListBoxCustomers) 'Diags - Returns
expected
value
stLinkCriteria = "[id]=" & Forms!frmCustomers!ListBoxCustomers
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

When the form opens, I get a dialogue box that says "Enter Paramter Value".
If I enter a known record ID, I get the expected record.

Can someone please advise what I need to change in then opening form to
accept the criteria and open the required record, without having to type it
into the "Enter Parameter Value" box?

Many Thanks!

Simon.
 
S

Simon Harris

Solved it...

This:
stLinkCriteria = "[id]=" & Chr$(34) & Forms!frmCustomers!ListBoxCustomers

Should have been:
stLinkCriteria = "[Customerid]=" & Chr$(34) &
Forms!frmCustomers!ListBoxCustomers

Cheers!
Simon.

Simon Harris said:
Hi Douglas,

Thanks for your post - Answers below...

Douglas J Steele said:
Does the message box display the correct value? From the naming
convention, Yes

I'm assuming that ListBoxCustomers is a list box. Is it set to
MultiSelect?
MultiSelect is set to 'None'
Does the Enter Parameter Value dialog list any part of
Forms!frmCustomers!ListBoxCustomers on it?
No, the title of the box is 'Enter Parameter Value' it then says ID with a
text input field and an OK button
What's the data type of ID: numeric or text?
Numeric


Do I need to do anything on the opening form to make it accept the
incoming variable/criteria? I created the form using the Wizard initially,
and then changed the layout.

Many Thanks,
Simon.

If it's text, try:

stLinkCriteria = "[id]=" & Chr$(34) & Forms!frmCustomers!ListBoxCustomers
&
Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Simon Harris said:
Hi All,

I am using the following code to open up a form following the user
double
clicking on an item in a listbox...

Private Sub ListBoxCustomers_DblClick(Cancel As Integer)
'Open selected customer for editing
stDocName = "frmAddEditCustomers"
MsgBox (Forms!frmCustomers!ListBoxCustomers) 'Diags - Returns
expected
value
stLinkCriteria = "[id]=" & Forms!frmCustomers!ListBoxCustomers
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

When the form opens, I get a dialogue box that says "Enter Paramter Value".
If I enter a known record ID, I get the expected record.

Can someone please advise what I need to change in then opening form to
accept the criteria and open the required record, without having to type it
into the "Enter Parameter Value" box?

Many Thanks!

Simon.
 

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