N
nouveauricheinvestments
Hi,
I want to call this function to look and see if a record has been
added to a table when the user updates specific areas of the database
with a form to confirm the record has been added. What would be the
correct way to incorporate a variable in the Rs.Find
("RepID=MyVariable") ? Thanks for your input in advance.
Public Sub LookUp(ByVal RPID As Integer)
Dim Cn As ADODB.Connection
Set Cn = New ADODB.Connection
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
Dim WhatToFind As String
With Rs
.ActiveConnection = CurrentProject.Connection
.Open "SELECT * FROM [Pending Tickets]"
.Find "('RepID=" & RPID & "')"
End With
On Error GoTo Handle
MsgBox Rs.Fields(4)
Rs.Close
Set Cn = Nothing
Set Rs = Nothing
TimeToLeave:
Exit Sub
Handle:
Select Case Err.Number
Case Is = 3021
VBA.MsgBox "The request you have made to update the database
with a new record was not processed." & _
"Please attempt to enter the record again; if you continue
to get this error, please contact " & _
"your database administrator for assistance.", vbCritical,
"Error Adding Record"
Case Else
VBA.MsgBox "There was an unknown error when trying to process
your request in the database. Please " & _
"report the specific request you were attempting to make
in the database and forward that information" & _
"to your database administrator in conjunction with the
error number. " & vbCrLf & vbCrLf & Err.Number
End Select
GoTo TimeToLeave
End Sub
I want to call this function to look and see if a record has been
added to a table when the user updates specific areas of the database
with a form to confirm the record has been added. What would be the
correct way to incorporate a variable in the Rs.Find
("RepID=MyVariable") ? Thanks for your input in advance.
Public Sub LookUp(ByVal RPID As Integer)
Dim Cn As ADODB.Connection
Set Cn = New ADODB.Connection
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
Dim WhatToFind As String
With Rs
.ActiveConnection = CurrentProject.Connection
.Open "SELECT * FROM [Pending Tickets]"
.Find "('RepID=" & RPID & "')"
End With
On Error GoTo Handle
MsgBox Rs.Fields(4)
Rs.Close
Set Cn = Nothing
Set Rs = Nothing
TimeToLeave:
Exit Sub
Handle:
Select Case Err.Number
Case Is = 3021
VBA.MsgBox "The request you have made to update the database
with a new record was not processed." & _
"Please attempt to enter the record again; if you continue
to get this error, please contact " & _
"your database administrator for assistance.", vbCritical,
"Error Adding Record"
Case Else
VBA.MsgBox "There was an unknown error when trying to process
your request in the database. Please " & _
"report the specific request you were attempting to make
in the database and forward that information" & _
"to your database administrator in conjunction with the
error number. " & vbCrLf & vbCrLf & Err.Number
End Select
GoTo TimeToLeave
End Sub