open args problem

  • Thread starter Thread starter RipperT
  • Start date Start date
R

RipperT

I have two forms: frmCharges and frmAdSeg. frmCharges has a field ChargeID
that, when double clicked should open the frmAdSeg with the value of the
ChargeID field inserted in the ChargeID (FK) field of the frmAdSeg. The code
for frmCharges.ChargeID is:

Private Sub ChargeID_DblClick(NewData as String, Cancel As Integer)
DoCmd.OpenForm "frmAdSeg", , , , acFormAdd, acDialog, NewData
Response = acDataErrContinue
End Sub

The code for frmAdSeg is:

Private Sub Form_Open(Cancel As Integer)
Dim strChargeID As String
strChargeID = Forms!frmAdSeg.OpenArgs
If Len(strChargeID) > 0 Then
DoCmd.GoToControl "ChargeID"
Me.ChargeID.Value = strChargeID
End IF
End Sub

Double clicking frmCharges.ChargeID produces an error: Procedure declaration
does not match the description of the event or procedure having the same
name.

I have similar code elsewhere in the DB between two forms and it works fine.
The only difference is that ChargeID is an Integer field, but the other form
uses a text field. This maybe the significant difference, but I don't know
how to make it work. Not too well versed in VB. Can someone please help?

Many thanx,

Ripper
 
a form control's DoubleClick event procedure does not have a NewData
argument or a Response argument. i'm guessing that you took those arguments
from a combo box control's NotInList event procedure - but you can't "make
up" an argument for an event procedure, or switch arguments around from one
event procedure to another.

the good news is: you don't have to. instead, try this

Private Sub ChargeID_DblClick(Cancel As Integer)

DoCmd.OpenForm "frmAdSeg", , , , acFormAdd, _
acDialog, Nz(Me!ChargeID.Text, "")

End Sub

and in frmAdSeg's Load event (instead of the Open event), try

Private Sub Form_Load()

If Not (Me.OpenArgs = "") Then
Me.ChargeID = Me.OpenArgs
End If

End Sub

hth
 
I had a suspicion there was a way easier way to accomplish this. I will try
it - thank you for the help.

Rip
 
Back
Top