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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Link forms with VBA code 1

Status
Not open for further replies.

Lavenderchan

Technical User
Jul 21, 2008
132
US
Hi I have a form that I'm using for work in access 2007. I enter a task on the main form and then it opens a form to enter the rest of the required information but I unsure on how to link those forms together so the record is in sink with both forms.

Thanks,
Keri
 
I set the break point but I don't understand what an os is. Right now the form is only opening in with the id showing as new instead of using the id. I just tring to understand why this isn't working.

Thanks,
Keri
 
An os is an 'is' with fat fingers :)

When you say new, you mean you have a blank form, yesno? If yes, do you want this blank form to be filled in with an id? If no, do you already have an id you want to find?



 
Yes its a blank form. I want to it to be filled in with an id from the previos form.
 
Put a breakpoint on this code:

Code:
Private Sub Form_Open(Cancel As Integer)
If Me.OpenArgs <> vbNullString Then
 Me.ID = Me.OpenArgs
End If
End Sub

And tell me what Me.OpenArgs contains. Is ID the name of the control you want to fill in?

 
The id is the name of the control I want but I'm not sure how to get the break point to run it highlights but I not sure what to do from there.
 
Hi Remu I keep getting the meessage Compile Error Varriable not yet created in this context.
 
No I did place in on the on load event and I getting the same message.
 
This code is on the form that then trrigers the on load event.

Private Sub Assigned_To_AfterUpdate()
If Me.cboTask = ("Excess Income Report") Then
DoCmd.OpenForm "Excess Income Details", , , "ID=" & "ID"
End If
If Me.cboTask = ("Reserve for Replacement") Then
DoCmd.OpenForm "Reserve for Replacement Details", , , "ID=" & "ID"
End If
End Sub

I have this place on the on load on the second and third forms.
Private Sub Form_Load()
If Me.OpenArgs <> vbNullString Then
Me.ID = Me.OpenArgs
End If
End Sub
Thanks,
keri
 
Also, we have two different ideas going on. In the thread above, we talked about using a Where statement, which is what you have for the first piece of code above, then we talked about using OpenArgs, which is what you have for the second piece of code. We need to settle on one idea.

 
Sorry I did change that part. I have had my coffe yet this morning please bare with me.

Private Sub Assigned_To_AfterUpdate()
If Me.cboTask = ("Excess Income Report") Then
DoCmd.OpenForm "Excess Income Details", , , "ID=" & Me!ID
End If
If Me.cboTask = ("Reserve for Replacement") Then
DoCmd.OpenForm "Reserve for Replacement Details", , , "ID=" & Me!ID
End If
End Sub
 
Ok the first part of the code is working its opening the form its the openargs.That isn't working they way it should.
 
That may be because you do not have any OpenArgs, you have a Where statement.

The OpenArgs idea is 17 Apr 09 9:42

[tt]DoCmd.OpenForm "Reserve for Replacement Details", , , acFormAdd, , Me.ID[/tt]


 
I added the code but I am getting a Runtime error message 2505 an expression in arguement 6 has an invalied value.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top