Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have two forms each of which are ba

Status
Not open for further replies.

Rufusjeep

Technical User
Nov 6, 2001
10
US
Have two forms each of which are based upon their own tables and are linked by a case number that is the primary key in the case table and a foreign key in the hearing table. Button on the case form that opens the hearing and let the user enter in the information that is needed for the hearing. My problem is that I can not get the case number to copy from the case form and be entered into the hearing from to work.

Here is the code that I am working with:

Dim stDocName As String
Dim stLinkCriteria As String
Dim caseNum As String

caseNum = Me![CASE_NUMBER]
stDocName = "frmCaseHearing"
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acDataForm, "frmCaseHearing", acNewRec
Me![CASE_NUMBER] = caseNum

When I click on the schedule hearing button where the code is, I get the following error:

The expression you entered refers to an object that is closed or doesn't exist.

What do I need to change in my code to get it to work?

Thanks in advance,

Mike
 
Try this:

If the second form is just a "new record" form (to schedule a new date) then I would do it this way.

Private Sub cmdSchedule_Click()
Dim stDocName As String
Dim stLinkCriteria As String
Dim caseNum As String

caseNum = Me![CASE_NUMBER]
stDocName = "frmCaseHearing"

DoCmd.OpenForm stDocName, , , stLinkCriteria,,casenum

DoCmd.Close
end sub

ON the frmSchedule Open Event
Private Sub Form_Open()
DoCmd.GoToRecord acDataForm, , acNewRec
me![Case_Number] = me.OpenArgs
end sub

Pass the ID value to second form using OpenArgs and set my new records case number to the openargs. That should work.

Hope that helps

Bob [spin2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top