how to use a run time variable as public
hi!
i m trying to use an integer "srchID" as publicly available variable.
whenever a user enters ID in a text box then my program will check if that id exists or not. if not it ignores, but if it exists it will assign the entered value val(txtEnterID.Text) = srchID
so i want to use this srchID in different forms to check functionality. i tried it as follows:
Private Sub cmdOk_Click() 'it is the main form where user enters ID
Dim sql, msg As String
Dim rs As New ADODB.Recordset
mdldb.dbconnect
Set rs = mdldb.conn.Execute("select StudentID from StudentProfile where StudentID = " & txtEnterID.Text & "")
If rs.EOF = True And rs.BOF = True Then
msg = MsgBox("This student doesn't exist", vbCritical)
Else
srchID = Val(" & txtEnterId.text &")
Load AccountsInfo 'i want to use srchID in this formAccountsInfo.Show
End If
End Sub
i defined srchID as Public, it doesn't show msg as the record doesn't exists but says either eof or bof is true or file is deleted.
Is there anyone who can help me?
thanx
Ana
|