|
-
Jun 21st, 2006, 11:04 AM
#1
Thread Starter
Hyperactive Member
Subform GoTo Record error
I am using access 2000 and having problems pointing to a specific recored on a subform.
I have a main form and subform(located on the main form) both pointing to the same table. Both main and subform are used to input data into the same table. I know you're wondering why don't I just put them together on a single form, right? Well, I have 4 subforms on that main form and depending on early selections by the user 1 of the 4 subform becomes visible.
Now, when the main form opens it is already pointing to a new record. I put a text box on both the main and subform which points to the primary key of the table (autonumber) so I could see what record it was currently on.
Once you start inputing data in the text boxes on the main form the AutoNumber textbox located on the main form automatically changes to (Example) 95 as you're entering data into the new record with the new primary key 95.
Then, once I move to the subform area located on the main form and start entering data into those textboxes the AutoNumber text box located on the subform section populates with 96 meaning you're putting it into a new record again which I don't want. I want the subform data to be inputted into the same record as the main form which was 95.
I tried changing the Cycle properties of the forms to Current Record, but that didn't work.
Another thing I tried was putting the following code into an Enter event for the subform so when the subform receives focus I could move the record to match the main form and not have it inputted into a new record again.
However, with all the codes below I would receive an error saying "You can't go to the specified record."
Any thoughts?
VB Code:
'Test1
DoCmd.GoToRecord , , acLast
'Test2
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToRecord , , acPrevious
'Test3
Do Until frmSub.txtPrimaryKey = frmMain.txtPrimaryKey
DoCmd.GoToRecord , , acNext
Loop
'Test4
Do Until frmSub.txtPrimaryKey = frmMain.txtPrimaryKey
DoCmd.GoToRecord , , acPrevious
Loop
'Test5
DoCmd.GoToRecord , , acGoTo, frmMain.txtPrimaryKey
'Test6
DoCmd.GoToRecord , , acGoTo, frmMain.txtPrimaryKey-1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|