Linking Buttons from one form to filter another

CherryBomb

Registered User.
Local time
Today, 07:55
Joined
Oct 11, 2011
Messages
14
I have one form that I use to keep off of our Suppliers information, they are kept in order by Supplier ID#. I have a button down at the bottom of the form that will take them to a form called "Rates". This is our $$ Rates for every supplier.

Is is possible to link the Rate button on the 1st Form to the 2nd Rate form, but when you click on it always it will always take you to the start of the Rates for that particular Supplier and Supplier ID#?
 
Hi CherryBomb,

When you link to the second form, you can use the docmd.openform and pass arguments to it.

Code:
DoCmd.OpenForm "Rates" , AcNormal,,"[COLOR="Red"][Supplier_ID][/COLOR] = " & [COLOR="Blue"]me.Supplier_Id[/COLOR]

[Supplier_ID] is the ID on the 'Rates' Form
me.Supplier_Id is the ID on the first form.

Does that help at all?

Rich
 
Is this something I can do in the button commands or do I need to go somewhere else for this? It looks more like coding. (I am not very advanced in Access as of yet)
 
Thank you for that link vbaInet, but I still don't understand where I am supposed to put that code. Even when I click on the button properties and go into arguments section I don't see any options for "DoCmd.OpenForm" I only see "OpenForm"
 
In the On Click event of the button click the elipsis (...) button, select Code Builder and click OK. That will take you to the code section.
 
So I attempted to use that code, but I must not be doing it right. Here is what I have ...

Private Sub Form_Current()
DoCmd.OpenForm "Company Information for Rates: Datasheet", acNormal, , "[Supplier Number] = " & Me.Supplier Number"
End Sub
 
What is the data type of Supplier Number?

By the way, you have very bad naming conventions. You should special characters and especially spaces in your field, table, form, query names.
 
What I name my forms are important to what you will see on them, it makes completed sense on our end. Data type for Supplier Number? It's a number ... they are "010489" always 6 digits, but of course the digits vary.
 
Whatever works for you. If you have spaces or special characters in your names you MUST always enclose them in square brackets.

I believe r.harrison gave you the right syntax too:
Code:
DoCmd.OpenForm "Company Information for Rates: Datasheet", acNormal, , "[Supplier Number] = " & Me![Supplier Number]
 
Okay, I fixed that, however, it's still not taking me anywhere when I click on the button that has that code in it. Is there something else that I am not doing right?

I wanted to open the form, "Company Information for Rates: Datasheet" on click, but to that particular company supplier number that you are currently viewing in the main Company Information page.
 
Do you have any other filters in the form? Is the form bound to a table?
 
Which form? The main database, or the one I am trying to connect the button to?
 
I thought it might be easiest to just show you what I am working with.

I need the "Rate" button on the Supplier Information page so that when you click it it takes you to the Rate page and also connects you to the supplier number you were viewing on the original page.
 

Attachments

  • supplier info.png
    supplier info.png
    37.2 KB · Views: 77
  • supplier rates.png
    supplier rates.png
    29.6 KB · Views: 86
I understood your requirement which was why you were given the code.

So do you have any filters (i.e. look in the Filter property) on your Rate form?

Also, what records does it show when you click on the button? Nothing or it shows a non-related record?
 

Users who are viewing this thread

Back
Top Bottom