For what it's worth, here is my complete setup. Maybe it will help or maybe it will just confuse but I'll outline it anyway.
I have a main form that has 3 buttons. Each button opens the same form (frm_Survey) but passes a different string to the form. When a button is clicked the main form is closed to prevent the user from pressing another button. The form that is opened is frm_Survey. The string that is passed from the button via OpenArgs is concatenated with an integer that the user enters in an unbound textbox on frm_Survey and that value is put in the table (tbl_Survey) and also populates a disabled field (txt_SuveyNumID).
So for example, the user hits the "Trawl" on the main form. The main form closes, frm_Survey opens, and 'TR' is passed to frm_Survey. On frm_Survey the user types in "2" and in txt_SurveyNumID you would see "TR2" which also gets entered into SurveyNum field of tbl_SurveyNum.
There is a button on frm_Survey that launches frm_Replicate. The concatenated field from frm_Survey (txt_SurveyNumID) should also show up on frm_Replicate (getting passed by OpenArgs) and be entered into the table that feeds frm_Replicate (tbl_Replicate - they are linked by a one to many relationship: one survey can have many replicates).
There is a button on frm_Replicate that adds a new record (New Replicate). The user should be able to add as many records as they like, keeping that concatenated field that was passed from frm_Survey (txt_SurveyNumID). When they are done, they should be able to click on a New Survey button that closes frm_Replicate and return to frm_Survey. Now the user can change the number in the integer field, which is concatenated with the string passed from the main form, click a button to open frm_Replicate again, and start over with the new concatenated value.
In other words, "New Survey" button closes frm_Replicate. Type "3" into the field on frm_Survey and you should now see "TR3". Hit "New Replicate" and frm_Replicate opens with "TR3" as Survey_Num.
I hope this isn't too confusing. If it would help to draw a picture I can do that if you tell me how to upload attachments.
Now here are my problems:
1) When I hit "New Replicate" button on frm_Replicate it doesn't advance to a new record. I get an error message: "Can't go to specified record". This is the code on the button:
Expand|Select|Wrap|Line Numbers
- Private Sub btnNewReplicate_Click()
- On Error GoTo Err_btnNewReplicate_Click
- DoCmd.GoToRecord , , acNewRec
- Exit_btnNewReplicate_Click:
- Exit Sub
- Err_btnNewReplicate_Click:
- MsgBox Err.Description
- Resume Exit_btnNewReplicate_Click
- End Sub
I have all sorts of code snippets that I can provide as well if that would help.
Thanks in advance and sorry for the long post!!
cheers,
melissa