Control Button

  • Thread starter Thread starter JDP
  • Start date Start date
J

JDP

In a form I created a control button to open a second form.
Works fine.
I would like the form to open the second form for the
current record WITHOUT having to enter the record number
into the popup window.
Currently I must either copy, and paste the record number
into the popup window, or I must retype the record
number.
This is what was generated from the wizard to create the
buton:
stLinkCriteria = "[Invoice_No]=" & "'" & Me![Import
Invoice data.Invoice_No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
It looks like it is storing the Invoice_No into a string,
and should be calling the string?

Is there a way in the event procedure to tell the button
to open the current active record?
Once I open the second form from the button,I created a
button that toggles me back to the first form, and when I
press the button to go to back to the first form it
retains this in memory, and opens the first form.
Further once I have entered the number, and gone to the
second form, I can toggle between the forms using the
buttons.
Any help would be greatly appreciated.
 
This should work, so let's work on the stLinkCriteria.

What is [Import Invoice data]? Is it the name of a table? A subform? Try
without that part of the expression.

If you open the table where the Invoice_No field is, in design view, what is
the Data Type of the field? If Number (not Text), drop the extra quotes.

You may then end up with just:
stLinkCriteria = "[Invoice_No] = " & Me.Invoice_No
 
First Allen thank you for getting back to me so quickly.

Import Invoice data is a table.
Invoice_No is a text field.
I get a popup box "Enter Parameter Value"
Enter the Invoice Number.
Only the first time I click the command button.

I tried your suggestion to change the code to
stLinkCriteria ="[Invoice_No]" = " & Me Invoice_No

I now get the message
The specified field '[Invoice_No]'could refer to more than
one table listed in the FROM clause of your SQL statement.

I do not have Invoice_No in any other table, I do have
several tables linked to this form through queries.

This one is like the itch that you just cannot reach, and
it is bugging the life out of me.


-----Original Message-----
This should work, so let's work on the stLinkCriteria.

What is [Import Invoice data]? Is it the name of a table? A subform? Try
without that part of the expression.

If you open the table where the Invoice_No field is, in design view, what is
the Data Type of the field? If Number (not Text), drop the extra quotes.

You may then end up with just:
stLinkCriteria = "[Invoice_No] = " & Me.Invoice_No

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

In a form I created a control button to open a second form.
Works fine.
I would like the form to open the second form for the
current record WITHOUT having to enter the record number
into the popup window.
Currently I must either copy, and paste the record number
into the popup window, or I must retype the record
number.
This is what was generated from the wizard to create the
buton:
stLinkCriteria = "[Invoice_No]=" & "'" & Me![Import
Invoice data.Invoice_No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
It looks like it is storing the Invoice_No into a string,
and should be calling the string?

Is there a way in the event procedure to tell the button
to open the current active record?
Once I open the second form from the button,I created a
button that toggles me back to the first form, and when I
press the button to go to back to the first form it
retains this in memory, and opens the first form.
Further once I have entered the number, and gone to the
second form, I can toggle between the forms using the
buttons.
Any help would be greatly appreciated.


.
 
So the form is based on a query, and the query has the Invoice_No field
twice?

Remove one if not needed.

Just noticed that the square brackets are wrong. Try:
stLinkCriteria = "[Import Invoice data].[Invoice_No] = """ & Me.Invoice_No &
""""

That assumes the text box is also named Invoice_No.

Alternatively, alias one of the fields in the query, e.g.:
SELECT [Import Invoice data].[Invoice_No] AS InvNo, ...
and then use:
stLinkCriteria = "InvNo = """ & Me.Invoice_No & """"

The extra quotes you had are valid, since this is a Text type field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JDP said:
First Allen thank you for getting back to me so quickly.

Import Invoice data is a table.
Invoice_No is a text field.
I get a popup box "Enter Parameter Value"
Enter the Invoice Number.
Only the first time I click the command button.

I tried your suggestion to change the code to
stLinkCriteria ="[Invoice_No]" = " & Me Invoice_No

I now get the message
The specified field '[Invoice_No]'could refer to more than
one table listed in the FROM clause of your SQL statement.

I do not have Invoice_No in any other table, I do have
several tables linked to this form through queries.

This one is like the itch that you just cannot reach, and
it is bugging the life out of me.


-----Original Message-----
This should work, so let's work on the stLinkCriteria.

What is [Import Invoice data]? Is it the name of a table? A subform? Try
without that part of the expression.

If you open the table where the Invoice_No field is, in design view, what is
the Data Type of the field? If Number (not Text), drop the extra quotes.

You may then end up with just:
stLinkCriteria = "[Invoice_No] = " & Me.Invoice_No

In a form I created a control button to open a second form.
Works fine.
I would like the form to open the second form for the
current record WITHOUT having to enter the record number
into the popup window.
Currently I must either copy, and paste the record number
into the popup window, or I must retype the record
number.
This is what was generated from the wizard to create the
buton:
stLinkCriteria = "[Invoice_No]=" & "'" & Me![Import
Invoice data.Invoice_No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
It looks like it is storing the Invoice_No into a string,
and should be calling the string?

Is there a way in the event procedure to tell the button
to open the current active record?
Once I open the second form from the button,I created a
button that toggles me back to the first form, and when I
press the button to go to back to the first form it
retains this in memory, and opens the first form.
Further once I have entered the number, and gone to the
second form, I can toggle between the forms using the
buttons.
Any help would be greatly appreciated.
 
Back
Top