Hiya
I get a run-time error No value for one or more the given parameters when running the following code.
Im running VB6 SP3 and trying to connection a Access 2000 db
Any help would be great.....this is the code ->
Private sub cmdTest_click
Dim objPatient As New clsPatient 'set new instance of object
On Error GoTo Error_Handler
CommonDialog1.DialogTitle = "Select a database"
CommonDialog1.Filter = "Access Files (*.mdb)|*.mdb"
CommonDialog1.InitDir = "C:\Test\"
CommonDialog1.FilterIndex = 1
CommonDialog1.Flags = cdlOFNFileMustExist + _
cdlOFNLongNames cdlOFNOverwritePrompt
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Set gcnDatabase = New ADODB.Connection
gcnDatabase.Provider = "Microsoft.jet.OLEDB.4.0"
gcnDatabase.Mode = adModeReadWrite
gcnDatabase.Open CommonDialog1.FileName
End If
objPatient.Load 4960 'Call the object
exit sub
Error_Handler:
end sub
____________________________________________________________
This is the code in the object:
Option Explicit
Private mflgLoading as boolean
Public Sub Load(Optional lngPatientKey As Long)
If mflgLoading Then Err.Raise 455
Loading
Fetch lngPatientKey
EndLoading
End Sub
Private Sub Fetch(lngStaffKey As Long)
Dim rsFetchRecord As ADODB.Recordset
Dim strSQL As String
Set rsFetchRecord = New ADODB.Recordset
strSQL = ""
strSQL = strSQL & "SELECT * FROM Staff "
strSQL = strSQL & "WHERE [StaffKey] = " & lngStaffKey
rsFetchRecord.Open strSQL, gcnDatabase, adOpenDynamic, adLockOptimistic
With rsFetchRecord
If Not (.BOF And .EOF) Then
mudtProps.PatientKey = !PatientKey
mudtProps.Surname = !Surname
End If
End With
Set rsFetchRecord = Nothing
End SubPrivate Sub Loading()
mflgLoading = True
End Sub
Private Sub EndLoading()
mflgLoading = False
End Sub
____________________________________________________________
Thanks in advance
Mike
I get a run-time error No value for one or more the given parameters when running the following code.
Im running VB6 SP3 and trying to connection a Access 2000 db
Any help would be great.....this is the code ->
Private sub cmdTest_click
Dim objPatient As New clsPatient 'set new instance of object
On Error GoTo Error_Handler
CommonDialog1.DialogTitle = "Select a database"
CommonDialog1.Filter = "Access Files (*.mdb)|*.mdb"
CommonDialog1.InitDir = "C:\Test\"
CommonDialog1.FilterIndex = 1
CommonDialog1.Flags = cdlOFNFileMustExist + _
cdlOFNLongNames cdlOFNOverwritePrompt
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Set gcnDatabase = New ADODB.Connection
gcnDatabase.Provider = "Microsoft.jet.OLEDB.4.0"
gcnDatabase.Mode = adModeReadWrite
gcnDatabase.Open CommonDialog1.FileName
End If
objPatient.Load 4960 'Call the object
exit sub
Error_Handler:
end sub
____________________________________________________________
This is the code in the object:
Option Explicit
Private mflgLoading as boolean
Public Sub Load(Optional lngPatientKey As Long)
If mflgLoading Then Err.Raise 455
Loading
Fetch lngPatientKey
EndLoading
End Sub
Private Sub Fetch(lngStaffKey As Long)
Dim rsFetchRecord As ADODB.Recordset
Dim strSQL As String
Set rsFetchRecord = New ADODB.Recordset
strSQL = ""
strSQL = strSQL & "SELECT * FROM Staff "
strSQL = strSQL & "WHERE [StaffKey] = " & lngStaffKey
rsFetchRecord.Open strSQL, gcnDatabase, adOpenDynamic, adLockOptimistic
With rsFetchRecord
If Not (.BOF And .EOF) Then
mudtProps.PatientKey = !PatientKey
mudtProps.Surname = !Surname
End If
End With
Set rsFetchRecord = Nothing
End SubPrivate Sub Loading()
mflgLoading = True
End Sub
Private Sub EndLoading()
mflgLoading = False
End Sub
____________________________________________________________
Thanks in advance
Mike