Related Record in second form

WJReid

Active Member
Joined
Jul 26, 2002
Messages
317
Hi All,

I have a field in a form called SalesID. I would like to open, from a button, a second form with costs on it and I would like it to open at the same SalesID record. Can anyone tell me the code for this?

Regards,

Bill
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Sure, something like this should work

DoCmd.OpenForm FormName:="MyFormName", WhereCondition:="[SalesID] = " & Me.txtSalesID

Where txtSalesID is the name of the text box where you have SalesID. If your ID is text, then you would change it to:

DoCmd.OpenForm FormName:="MyFormName", WhereCondition:="[SalesID] = '" & Me.txtSalesID & "'"

Note that you may also need to move the focus to the textbox before running the OpenForm method:

Me.txtSalesID.SetFocus

HTH,

Russell
 
Upvote 0
Hi again Russell,

I guess I was just lucky the first time I ran the code, I was in record number 3 and it worked OK. Any other record, it opens the form at a new record. Any ideas?

Regards,

Bill
 
Upvote 0
Hi Russell,

I shut the computer down last night, opened it up this morning and it was working OK. Thanks again for your help.

Regards,

Bill
 
Upvote 0
Funny, that's the kind of advice that I get from our IT people at work!

"Try turning your computer off"

I think that since it works in about 1 out of 500 cases, it has made it to their "troubleshooting" guide.

:biggrin:
 
Upvote 0
Nice to know that I'm only 1 in 500, makes me feel kind of important.

I used to get that kind of advice from IT as well, but I guess I won't be telling them that I did it and it worked, otherwise it will be first item in the manual.

Bill
 
Upvote 0

Forum statistics

Threads
1,221,501
Messages
6,160,175
Members
451,629
Latest member
MNexcelguy19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top