Question Finding the same record in a new form

mitch_johnson

Registered User.
Local time
Today, 12:54
Joined
Mar 18, 2009
Messages
40
hello does anybody know how to do the follwoing:

when i click a link of one form to open up a new one how can i have it automaticly direct me to the record i was looking at on the first form

hope you understand and please explain in steps as i am quite new to VB coding thanks
 
sorry i cant get this to work can you give any other ideas thanks
 
sorry i cant get this to work can you give any other ideas thanks

Big TIP here Mitch - If something doesn't work, don't just say "I can't get this to work." We can't read minds so we don't know exactly what you've tried. Be descriptive. We can't see your database (unless you post it) so we have no idea of how you've created your forms, what your records look like, etc.
 
ok sorry i have one form with some customers infomation on it eg- First Name, Surname, Customer ID ETC... what i want to do is when i click a button to open up a second form to show extra details of the customer eg - Address, Telephone number ETC for the record on the second form to be the same as the one i was looking at on the first form as whats happening at the moment is when i click my button to load the second form it loads and then just stays at record 1 i want it to find the record i was viewing in my first form hope this helps thanks
 
ok sorry i have one form with some customers infomation on it eg- First Name, Surname, Customer ID ETC... what i want to do is when i click a button to open up a second form to show extra details of the customer eg - Address, Telephone number ETC for the record on the second form to be the same as the one i was looking at on the first form as whats happening at the moment is when i click my button to load the second form it loads and then just stays at record 1 i want it to find the record i was viewing in my first form hope this helps thanks

What I meant was what code did you try from Paul's site that didn't work?
 
i tried:
DoCmd.OpenForm "SecondFormName", , , "FieldName = " & Me.ControlName
i dont really understand the field name and controlname bit either would you mind explaining it a bit better and give me some examples thanks a lot
 
i tried:
DoCmd.OpenForm "SecondFormName", , , "FieldName = " & Me.ControlName

Okay, you need to replace SecondFormName with the name of YOUR second form you are opening.

Your FieldName is what field is the field that ties the data between forms together (usually it is the Primary Key of the record). So if you have CustomerID as a field and that identifies the record you are on, you would use CustomerID and if you have spaces you would use square brackets like [Customer ID].

Me.ControlName is the name of the control on FORM 1, that has the same information as the FieldName would in Form 2. So, if you have a text box that has the CustomerID in it then you would use that.

For example, if I had a Form named "CustomerDetails" that I wanted to open to [Customer ID] from my main form which had CustomerID in the text box named txtCustID then I would use this code:
Code:
DoCmd.OpenForm "CustomerDetails", , , "[Customer ID] = " & Me.txtCustID

If the Customer ID was text instead of numeric I would need to encapsulate it in quotes. I will use the CHR(34) character nowdays due to potential single quotes being in the text which can screw things up. So I would use for that:

Code:
DoCmd.OpenForm "CustomerDetails", , , "[Customer ID] = " & Chr(34) & Me.txtCustID & Chr(34)
 
i still can get it to work i keep getting synax error and i dont really understand what the controll name is
 
ControlName should be the name of the textbox or other control on the first form that contains the value you want the second form filtered on.
 

Users who are viewing this thread

Back
Top Bottom