By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,117 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,117 IT Pros & Developers. It's quick & easy.

Open form to specific record

P: 1
I have read several responses to this problem around the web, but my programming knowledge wasn't strong enough to translate those responses to my problem.

I have a database with one table, the primary key of this table is called ID Number (It is a number, not a string). There are two forms in the database, and I made a button to switch from one form to the other. When I am in Form1, I want to be able to click the button to go to Form2, while remaining on the same record (I would prefer if Form2 was now filtered so you cannot scroll to any other records).

The command DoCmd.OpenForm "Form2" does not work since it will open to record 1 every time. I have also tried DoCmd.OpenForm "Form 2" , , , [ID Number] = Me! [ID Number] but that produced an error. I think I might not have the right syntax or I might be writing [ID Number] incorrectly.
May 5 '07 #1
Share this Question
Share on Google+
4 Replies


JConsulting
Expert 100+
P: 603
I have read several responses to this problem around the web, but my programming knowledge wasn't strong enough to translate those responses to my problem.

I have a database with one table, the primary key of this table is called ID Number (It is a number, not a string). There are two forms in the database, and I made a button to switch from one form to the other. When I am in Form1, I want to be able to click the button to go to Form2, while remaining on the same record (I would prefer if Form2 was now filtered so you cannot scroll to any other records).

The command DoCmd.OpenForm "Form2" does not work since it will open to record 1 every time. I have also tried DoCmd.OpenForm "Form 2" , , , [ID Number] = Me! [ID Number] but that produced an error. I think I might not have the right syntax or I might be writing [ID Number] incorrectly.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "YourForm", , , "[ID Number]=" & Me.[ID Number]
May 5 '07 #2

P: 18
I have a similar problem, but with a tabbed control,
i have a main form that is on a set record, i have a button on it to open a tabbed control that has numerous files embeded in it that contain the related information to it,
ive tried the normal
DoCmd.OpenForm "YourForm", , , "[ID Number]=" & Me.[ID Number]
that doesnt work, even if i put a copy of the ID control of the main form on the tab container form which I realise isnt linked to the other forms anyway, i need the way to link them.
the tab control is the only thing on the form, is there a way to link the tabbed forms together to respond to the main form... I hope this one makes sense.
May 6 '07 #3

JConsulting
Expert 100+
P: 603
I have a similar problem, but with a tabbed control,
i have a main form that is on a set record, i have a button on it to open a tabbed control that has numerous files embeded in it that contain the related information to it,
ive tried the normal
DoCmd.OpenForm "YourForm", , , "[ID Number]=" & Me.[ID Number]
that doesnt work, even if i put a copy of the ID control of the main form on the tab container form which I realise isnt linked to the other forms anyway, i need the way to link them.
the tab control is the only thing on the form, is there a way to link the tabbed forms together to respond to the main form... I hope this one makes sense.

Shouldn't this be a separate question?
The problem you're having with your tab control is that you lose the record number as soon as you leave the record to press the button. Your case would have to point to the ID on the parent form IF it is linked to the record on the tabbed form. Normally you link tabbed forms together by putting a text box on the main form with the primary ID and link your subforms to it using the Master/Child relationship.
J
May 6 '07 #4

P: 18
Shouldn't this be a separate question?
The problem you're having with your tab control is that you lose the record number as soon as you leave the record to press the button. Your case would have to point to the ID on the parent form IF it is linked to the record on the tabbed form. Normally you link tabbed forms together by putting a text box on the main form with the primary ID and link your subforms to it using the Master/Child relationship.
J
Yes that was the problem, now solved after a days dig round,
using this

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.[Inspection ID] = Forms![Booking Form]![ID]
End Sub

and taking the forms in the tabs off queries and back to straight from the tables which then allowed me to set the links via the wizard also.

working ok now
thanks for the efforts...
May 7 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.