Command Button Issues.

SpiritedAway

Registered User.
Local time
Yesterday, 19:57
Joined
Sep 17, 2009
Messages
97
Hi.

On my Mainform [frmMain] there is a subform [subEmployee]

I have a command button on the main form - i'm trying to get it to open another form [frmSales] where [EmpID] of [subEmployee] is equal to [EmpID] of [frmSales] (the form I want to open).

I/m stuck with getting a command button on a main form to open another form where the ID on the subform matches the ID on the form I want to open.

Can anyone give me some pointers.

I'm using Access 2007

Thanks
 
Look at "DemoSubSubCA2000.mdb" (attachment, zip).
Look at Tables, Forms (VBA), Relationships.
Open frmMain and try.
I think it can halp you.
 

Attachments

Hi

MStef, I've taken a look at the demo - the button is in the subform footer - I need the button on the main form to do exactly as it would do if it were placed in the subform.

I will take a look at the VBA -

vbaInet - I'm going to have a look at the link now -
 
My code for opening a form called frmScores which needs to relate to the contactID in the frmContacts is this...

The contactID from scores form needs to match contactID in contacts form

Private Sub cmdOpenScores_Click()
On Error GoTo Err_cmdOpenScores_Click

DoCmd.OpenForm "frmScores", , , "[contactID]=" & Me.txtcontactID, , , Me.txtcontactID
Exit_cmdOpenScores_Click:
Exit Sub
Err_cmdOpenScores_Click:
MsgBox Err.Description
Resume Exit_cmdOpenScores_Click

End Sub

I would try replacing the frmNames and field names with the ones you use.

So maybe yours could be:

Code:
Private Sub cmdOpenfrmSales_Click()
On Error GoTo Err_cmdOpenfrmSales_Click
    
    DoCmd.OpenForm "frmSales", , , "[EmpID]=" & Me.EmpID, , , Me.EmpID
Exit_cmdOpenfrmSales_Click:
    Exit Sub
Err_cmdOpenfrmSales_Click:
    MsgBox Err.Description
    Resume Exit_cmdOpenfrmSales_Click
    
End Sub
 
My code for opening a form called frmScores which needs to relate to the contactID in the frmContacts is this...

The contactID from scores form needs to match contactID in contacts form



I would try replacing the frmNames and field names with the ones you use.

So maybe yours could be:

Code:
Private Sub cmdOpenfrmSales_Click()
On Error GoTo Err_cmdOpenfrmSales_Click
    
    DoCmd.OpenForm "frmSales", , , "[EmpID]=" & Me.EmpID, , , Me.EmpID
Exit_cmdOpenfrmSales_Click:
    Exit Sub
Err_cmdOpenfrmSales_Click:
    MsgBox Err.Description
    Resume Exit_cmdOpenfrmSales_Click
    
End Sub
That was basically what was in the link provided.
 
Haha!! No problemo! Was just redirecting the OP to the link as it explains how it works ;)
 

Users who are viewing this thread

Back
Top Bottom