Missed value passed with OpenArgs

  • Thread starter Thread starter Alex Vizuete
  • Start date Start date
A

Alex Vizuete

hi, i have the following trouble:
i'm trying to pass an argument to a second form throught openargs, but when
i try to get the passed value from openargs it is nothing, i confirmed that
sArgs have a value at call

my call at the first form is

Private Sub CmdCatalogo_Click()
Dim fCtas As New Form_Frm_Cuentas
Dim sArgs As String

sArgs = CStr(iIdEmpresa) & "-" & sNomEmpresa
sName = fCtas.Name
DoCmd.OpenForm fCts.Name, , , , , , sArgs
Set fCtas = Nothing
End Sub

this code goes at the second form
Private Sub Form_Open(Cancel As Integer)
Dim sSqlStmt As String, sParam() As String

If Not IsNull(Me.OpenArgs) Then
sParam = Split(Me.OpenArgs, "-")

MsgBox "IdEmpresa = " & iIdEmpresa
sSqlStmt = "SELECT Cuentas.[P&L], Cuentas.Clss, Cuentas.Cat,
Cuentas.Group, Cuentas.Seq, " _
& "Cuentas.IMI_Code, Cuentas.[Group/Account_Name],
Cuentas.[Mercom_Code], Cuentas.Description " _
& "FROM Cuentas " _
& "WHERE IdEmpresa = " & CLng(sParam(0)) & " ORDER BY
Cuentas.[P&L], Cuentas.Clss, Cuentas.Cat, Cuentas.Group, Cuentas.Seq;"

Me.lblEmpresa.Caption = vbNullString
Me.lblEmpresa.Tag = vbNullString
If CLng(sParam(0)) = 0 Then
MsgBox "Seleccione la empresa de trabajo.", vbInformation
Cancel = True
Exit Sub
End If
Me.lblEmpresa.Caption = sParam(1)
Me.lblEmpresa.Tag = sParam(0)
Else
MsgBox "Debe seleccionar una empresa.", vbInformation
Cancel = True
End If
End Sub

aditionally at the second form when assign cancel=true i get an error "Run
time error 2001. You canceled the previous operation", at this line
"DoCmd.OpenForm fCts.Name, , , , , , sArgs"
in the first form

Best Regards,
Alex Vizuete

PD: sorry for my english...
 
Back
Top