S
s.f.
Hi, I am using Access 2002.
I tried to set up an unbound texbox in form so that users can type in a
value to find a specific record to update other fields.
For the unbound textbox (named ttrackid) I put in the following VBA codes
for event procedure on EXIT (please see below). However, the line " Dim
currdb As Database" was highlighted and I received an error msg saying --
Compile error:
user-defined type not defined.
Please help. The codes were working fine in another database.
Thank you,
Private Sub ttrackid_Exit(Cancel As Integer)
On Error GoTo Err_ttrackid_exit
Dim currdb As Database
Set currdb = CurrentDb()
' If ttrackid is BLANK
If IsNull(Me![ttrackid]) Then
' Do nothing but leave subroutine. Any msg gets in way.
'MsgBox "The ENTER TRACKID box is empty."
Exit Sub
End If
' If ttrackid NOT BLANK,
' check to see if ttrackid exists already
If Not IsNull(Me![ttrackid]) Then
Dim rsTRACKID As Recordset
Set rsTRACKID = currdb.OpenRecordset _
("select * from QFUIX where " & _
"QFUIX![TRACKID] =" & Me![ttrackid])
Dim intCountTRACKID As Integer
intCountTRCKID = rsTRACKID.RecordCount
End If
' If TRACKID DOES NOT EXIST,
If intCountTRACKID = 0 Then
MsgBox "This TRACKID does not exist. " & _
"Enter another TRACKID or leave blank."
Forms!FUIXForm!TRACKID.SetFocus
Forms!FUIXForm!ttrackid.SetFocus
' If TRACKID EXISTS, show record
Else
[Forms]![FUIXForm]![TRACKID].SetFocus
DoCmd.FindRecord Me![ttrackid], , , , 0
Me![ttrackid] = Null
Exit Sub
End If
Exit_ttrackid_exit:
Exit Sub
Err_ttrackid_exit:
MsgBox Err.Description
Resume Exit_ttrackid_exit
End Sub
I tried to set up an unbound texbox in form so that users can type in a
value to find a specific record to update other fields.
For the unbound textbox (named ttrackid) I put in the following VBA codes
for event procedure on EXIT (please see below). However, the line " Dim
currdb As Database" was highlighted and I received an error msg saying --
Compile error:
user-defined type not defined.
Please help. The codes were working fine in another database.
Thank you,
Private Sub ttrackid_Exit(Cancel As Integer)
On Error GoTo Err_ttrackid_exit
Dim currdb As Database
Set currdb = CurrentDb()
' If ttrackid is BLANK
If IsNull(Me![ttrackid]) Then
' Do nothing but leave subroutine. Any msg gets in way.
'MsgBox "The ENTER TRACKID box is empty."
Exit Sub
End If
' If ttrackid NOT BLANK,
' check to see if ttrackid exists already
If Not IsNull(Me![ttrackid]) Then
Dim rsTRACKID As Recordset
Set rsTRACKID = currdb.OpenRecordset _
("select * from QFUIX where " & _
"QFUIX![TRACKID] =" & Me![ttrackid])
Dim intCountTRACKID As Integer
intCountTRCKID = rsTRACKID.RecordCount
End If
' If TRACKID DOES NOT EXIST,
If intCountTRACKID = 0 Then
MsgBox "This TRACKID does not exist. " & _
"Enter another TRACKID or leave blank."
Forms!FUIXForm!TRACKID.SetFocus
Forms!FUIXForm!ttrackid.SetFocus
' If TRACKID EXISTS, show record
Else
[Forms]![FUIXForm]![TRACKID].SetFocus
DoCmd.FindRecord Me![ttrackid], , , , 0
Me![ttrackid] = Null
Exit Sub
End If
Exit_ttrackid_exit:
Exit Sub
Err_ttrackid_exit:
MsgBox Err.Description
Resume Exit_ttrackid_exit
End Sub