G
Garret
I have converted an Access97 *.mdb to Access2K *.mdb. I am starting to got
thru and covert to ADO.
I am having a bit a trouble setting the recordsource of a simple form. I
have two unbound fields (SerialNumber & PartNumber) that are used to collect
data to check for exisiting records. I have a third field hidden field
(DRnum) that is eventually used as to link a subform. For trouble shooting,
I have deleted the subform, as I cannot seem to set the recordsource of the
form. I get a "you cancelled the previous operation" error.
My basic idea is that I use the AfterUpdate event to go and select the
DRnum and PartNumber for a particular SerialNumber. I know I am returning
records, as the msgbox RS0("DRnum") give me the correct result. I get the
"you cancelled the previos operation" error when Me.RecordSource =
strCheckPnSn is interpreted. Any Ideas??
Here is the code:
Private Sub SerialNumber_AfterUpdate()
On Error GoTo Err_ERRORFR
Dim strCheckPnSn As String
Dim RS0 As ADODB.Recordset
Set RS0 = New ADODB.Recordset
'Build string to check for pn and sn record
strCheckPnSn = "Select DRnum,PartNumber,SerialNumber from tblParts Where
SerialNumber Like '%" & Me("SerialNumber") & "%';"
MsgBox strCheckPnSn
If IsNull(Me("SerialNumber")) Then
' Why bother opening the recordset if you don't have
' the necessary data?
MsgBox "please enter the part number"
Me("PartNumber").SetFocus
Else
RS0.Open strCheckPnSn, CurrentProject.Connection, adOpenDynamic
'RS0.Open strCheckPnSn, CurrentProject.Connection, adOpenDynamic,
adLockReadOnly
MsgBox RS0("DRnum")
If Not RS0.BOF And Not RS0.EOF Then
Me.RecordSource = "Select DRnum,PartNumber,SerialNumber
from tblParts Where drNum = '27';"
End If
End If
Set RS0 = Nothing
Exit_ERRORFR:
Exit Sub
Err_ERRORFR:
MsgBox Err.Description
Resume Exit_ERRORFR
thru and covert to ADO.
I am having a bit a trouble setting the recordsource of a simple form. I
have two unbound fields (SerialNumber & PartNumber) that are used to collect
data to check for exisiting records. I have a third field hidden field
(DRnum) that is eventually used as to link a subform. For trouble shooting,
I have deleted the subform, as I cannot seem to set the recordsource of the
form. I get a "you cancelled the previous operation" error.
My basic idea is that I use the AfterUpdate event to go and select the
DRnum and PartNumber for a particular SerialNumber. I know I am returning
records, as the msgbox RS0("DRnum") give me the correct result. I get the
"you cancelled the previos operation" error when Me.RecordSource =
strCheckPnSn is interpreted. Any Ideas??
Here is the code:
Private Sub SerialNumber_AfterUpdate()
On Error GoTo Err_ERRORFR
Dim strCheckPnSn As String
Dim RS0 As ADODB.Recordset
Set RS0 = New ADODB.Recordset
'Build string to check for pn and sn record
strCheckPnSn = "Select DRnum,PartNumber,SerialNumber from tblParts Where
SerialNumber Like '%" & Me("SerialNumber") & "%';"
MsgBox strCheckPnSn
If IsNull(Me("SerialNumber")) Then
' Why bother opening the recordset if you don't have
' the necessary data?
MsgBox "please enter the part number"
Me("PartNumber").SetFocus
Else
RS0.Open strCheckPnSn, CurrentProject.Connection, adOpenDynamic
'RS0.Open strCheckPnSn, CurrentProject.Connection, adOpenDynamic,
adLockReadOnly
MsgBox RS0("DRnum")
If Not RS0.BOF And Not RS0.EOF Then
Me.RecordSource = "Select DRnum,PartNumber,SerialNumber
from tblParts Where drNum = '27';"
End If
End If
Set RS0 = Nothing
Exit_ERRORFR:
Exit Sub
Err_ERRORFR:
MsgBox Err.Description
Resume Exit_ERRORFR