WHERE condition

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a button that,when clicked,opens another form according to WHERE
condition,that's the following : [Customer]=[Forms]![Customerform]![Customer]
The strange problem is that the result of clicking on this button may
display a customer's name that's different form the one predetermined,and
when i click on the [customer name] box ,it displays the correct customer
name.
Please advise
 
What is your button's code?

If you use the Access button wizard to create the button's code, it
will be something like this:


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form2Name"

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


Will that work?

Or are you using a query (with search criteria taken from your
Customerform) as the Record Source for you second form? That's an
extra step but it should work as well. But if your second form was
already open with previous data, you need to do a requery so the form
reads the new query results. For example:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form2"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!Form2.Requery
 
I have a button that,when clicked,opens another form according to WHERE
condition,that's the following : [Customer]=[Forms]![Customerform]![Customer]
The strange problem is that the result of clicking on this button may
display a customer's name that's different form the one predetermined,and
when i click on the [customer name] box ,it displays the correct customer
name.
Please advise

Please post your code, and (if it's a parameter query) the
Recordsource query SQL of the second form.

John W. Vinson[MVP]
 
Here's the code:
DoCmd.OpenForm , acNormal, , [Customer] = [Forms]![Customerform]![Customer],
acFormEdit, acWindowNormal


John Vinson said:
I have a button that,when clicked,opens another form according to WHERE
condition,that's the following : [Customer]=[Forms]![Customerform]![Customer]
The strange problem is that the result of clicking on this button may
display a customer's name that's different form the one predetermined,and
when i click on the [customer name] box ,it displays the correct customer
name.
Please advise

Please post your code, and (if it's a parameter query) the
Recordsource query SQL of the second form.

John W. Vinson[MVP]
 
If Customer is a numeric field:

DoCmd.OpenForm , acNormal, , "[Customer] = " &
[Forms]![Customerform]![Customer], acFormEdit, acWindowNormal

If it's text:

DoCmd.OpenForm , acNormal, , "[Customer] = " & Chr$(34) &
[Forms]![Customerform]![Customer] & Chr$(34), acFormEdit, acWindowNormal


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Pietro said:
Here's the code:
DoCmd.OpenForm , acNormal, , [Customer] =
[Forms]![Customerform]![Customer],
acFormEdit, acWindowNormal


John Vinson said:
I have a button that,when clicked,opens another form according to WHERE
condition,that's the following :
[Customer]=[Forms]![Customerform]![Customer]
The strange problem is that the result of clicking on this button may
display a customer's name that's different form the one
predetermined,and
when i click on the [customer name] box ,it displays the correct
customer
name.
Please advise

Please post your code, and (if it's a parameter query) the
Recordsource query SQL of the second form.

John W. Vinson[MVP]
 

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

Back
Top