Open form to specific record | Newbie | | Join Date: May 2007
Posts: 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.
|  | Expert | | Join Date: Apr 2007 Location: Houston
Posts: 601
| | | re: Open form to specific record Quote:
Originally Posted by SDave 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. - DoCmd.OpenForm "YourForm", , , "[ID Number]=" & Me.[ID Number]
| | Newbie | | Join Date: May 2007 Location: China
Posts: 18
| | | re: Open form to specific record
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.
|  | Expert | | Join Date: Apr 2007 Location: Houston
Posts: 601
| | | re: Open form to specific record Quote:
Originally Posted by oldroboman 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
| | Newbie | | Join Date: May 2007 Location: China
Posts: 18
| | | re: Open form to specific record Quote:
Originally Posted by JConsulting 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...
|  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,272 network members.
|