D
Deanna
Below is my code. I don't know why I get the Object Variable not Set error.
Any help will be deeply appreciated.
Thanks!
Deanna
Private Function AddEmployeeInfo()
'OLD CODE
'Dim wrkODBC As Workspace
'Dim cnn As Connection
'Dim qdfTemp As QueryDef
'Added 3/11/09
Dim DB As Database
Set DB = CurrentDb()
Dim qryd As QueryDef
On Error GoTo AddEmployeeInfo_Err_Handler
DoCmd.Hourglass True
GetValues
'OLD CODE
'Set wrkODBC = CreateWorkspace("NewODBCWorkspace", "admin", "", dbUseODBC)
'Set cnn = "ODBC;DSN=CWD To TEST DB;DBQ=Wolf;UID=MUNDIR;PWD=Telly"
'Set qdfTemp = cnn.CreateQueryDef("", "{CALL INSERT_EMPLOYEE_INFO('" &
sFirst & "','" & sMiddle & "','" & sLast & "','" & sPreferred & "','" &
lEmployeeNum & "','" & sSuffix & "','" & sTitleAfter & "','" & sTitleBefore &
"','" & lMainDep & "','" & lCommonID & "','" & lCityMail & "','" & sRoomNum &
"','" & sRoomType & "','" & sFloorNum & "','" & sTArea & "','" & sTPrefix &
"','" & sTSuffix & "','" & sFArea & "','" & sFPrefix & "','" & sFSuffix &
"','" & sPArea & "','" & sPPrefix & "','" & sPSuffix & "','" & sCArea & "','"
& sCPrefix & "','" & sCSuffix & "','" & sEmail & "', '" & sLstComment & "',
'" & iTypeID & "')}")
'qdfTemp.Execute dbExecDirect
'cnn.Close
'wrkODBC.Close
'Added 3/11/09
Set qryd = DB.CreateQueryDef("")
qryd.Connect = "ODBC;DSN=CWD To TEST DB;DBQ=Wolf;UID=MUNDIR;PWD=Telly"
qryd.SQL = "{CALL INSERT_EMPLOYEE_INFO('" & sFirst & "','" & sMiddle &
"','" & sLast & "','" & sPreferred & "','" & lEmployeeNum & "','" & sSuffix &
"','" & sTitleAfter & "','" & sTitleBefore & "','" & lMainDep & "','" &
lCommonID & "','" & lCityMail & "','" & sRoomNum & "','" & sRoomType & "','"
& sFloorNum & "','" & sTArea & "','" & sTPrefix & "','" & sTSuffix & "','" &
sFArea & "','" & sFPrefix & "','" & sFSuffix & "','" & sPArea & "','" &
sPPrefix & "','" & sPSuffix & "','" & sCArea & "','" & sCPrefix & "','" &
sCSuffix & "','" & sEmail & "', '" & sLstComment & "', '" & iTypeID & "')}"
qryd.ReturnsRecords = False
qryd.Execute
qryd.Close
DoCmd.Hourglass False
Exit Function
AddEmployeeInfo_Err_Handler:
'cnn.Close
'wrkODBC.Close
DoCmd.Hourglass False
MsgBox "An error has occurred in AddEmployeeInfo section of frmPerson.
" & Err.Description
Exit Function
End Function
Any help will be deeply appreciated.
Thanks!
Deanna
Private Function AddEmployeeInfo()
'OLD CODE
'Dim wrkODBC As Workspace
'Dim cnn As Connection
'Dim qdfTemp As QueryDef
'Added 3/11/09
Dim DB As Database
Set DB = CurrentDb()
Dim qryd As QueryDef
On Error GoTo AddEmployeeInfo_Err_Handler
DoCmd.Hourglass True
GetValues
'OLD CODE
'Set wrkODBC = CreateWorkspace("NewODBCWorkspace", "admin", "", dbUseODBC)
'Set cnn = "ODBC;DSN=CWD To TEST DB;DBQ=Wolf;UID=MUNDIR;PWD=Telly"
'Set qdfTemp = cnn.CreateQueryDef("", "{CALL INSERT_EMPLOYEE_INFO('" &
sFirst & "','" & sMiddle & "','" & sLast & "','" & sPreferred & "','" &
lEmployeeNum & "','" & sSuffix & "','" & sTitleAfter & "','" & sTitleBefore &
"','" & lMainDep & "','" & lCommonID & "','" & lCityMail & "','" & sRoomNum &
"','" & sRoomType & "','" & sFloorNum & "','" & sTArea & "','" & sTPrefix &
"','" & sTSuffix & "','" & sFArea & "','" & sFPrefix & "','" & sFSuffix &
"','" & sPArea & "','" & sPPrefix & "','" & sPSuffix & "','" & sCArea & "','"
& sCPrefix & "','" & sCSuffix & "','" & sEmail & "', '" & sLstComment & "',
'" & iTypeID & "')}")
'qdfTemp.Execute dbExecDirect
'cnn.Close
'wrkODBC.Close
'Added 3/11/09
Set qryd = DB.CreateQueryDef("")
qryd.Connect = "ODBC;DSN=CWD To TEST DB;DBQ=Wolf;UID=MUNDIR;PWD=Telly"
qryd.SQL = "{CALL INSERT_EMPLOYEE_INFO('" & sFirst & "','" & sMiddle &
"','" & sLast & "','" & sPreferred & "','" & lEmployeeNum & "','" & sSuffix &
"','" & sTitleAfter & "','" & sTitleBefore & "','" & lMainDep & "','" &
lCommonID & "','" & lCityMail & "','" & sRoomNum & "','" & sRoomType & "','"
& sFloorNum & "','" & sTArea & "','" & sTPrefix & "','" & sTSuffix & "','" &
sFArea & "','" & sFPrefix & "','" & sFSuffix & "','" & sPArea & "','" &
sPPrefix & "','" & sPSuffix & "','" & sCArea & "','" & sCPrefix & "','" &
sCSuffix & "','" & sEmail & "', '" & sLstComment & "', '" & iTypeID & "')}"
qryd.ReturnsRecords = False
qryd.Execute
qryd.Close
DoCmd.Hourglass False
Exit Function
AddEmployeeInfo_Err_Handler:
'cnn.Close
'wrkODBC.Close
DoCmd.Hourglass False
MsgBox "An error has occurred in AddEmployeeInfo section of frmPerson.
" & Err.Description
Exit Function
End Function