G
Guest
Please Help… I have a button on a unbound form,
that fires a macro to run the code below… however…
I keep getting
[Microsoft] [ODBC Driver Manager] Data source name not found and no default
driver specified
I believe I have everything as far as Access installed correctly…
Is there a problem with my code?
Public Function Update_Assign() As String
'Error Handling
On Error GoTo Err_Update_Assign_Click
'Establish
Dim allRecords As ADODB.Recordset
Dim cnCh5 As ADODB.Connection
Dim strConnection As String
Dim cmdCommand As ADODB.Command
Set cmdCommand = New ADODB.Command
Dim MySQL As String
Set cnCh5 = New ADODB.Connection
cnCh5.Open strConnection
Dim prompt, buttons, title
Dim Doc_Type As Integer
Doc_Type = Forms!Assignment_frm!Type_ID
Dim Buyer As Integer
Buyer=Forms!Assignment_frm!Assign_Buyer
Dim C_Date As Date
C_Date = Date
Dim Comments As String
If IsNull(Forms!Assignment_frm!Comments.Value) = True Then
Comments = "N / A"
Else
Comments = Forms!Assignment_frm!Comments
End If
MySQL = "INSERT INTO Assignment_History(Type_ID, Doc_ID, Buyer,
Assigned_Date, Comments) " & _
"VALUES (" & _
"'" & Doc_Type & "', " & _
"'" & Doc_No & "', " & _
"'" & Buyer & "', " & _
"'" & C_Date & "', " & _
"'" & Comments & "', "
prompt = "Assignment History updated."
buttons = vbOKOnly
title = "Notification"
Update_Assign = MsgBox(prompt, buttons, title)
Set cmdCommand.ActiveConnection = cnCh5
'set the SQL statement to the command text
cmdCommand.CommandText = MySQL
'execute command
cmdCommand.Execute
Set allRecords.ActiveConnection = cnCh5
allRecords.Requery
Set allRecords.ActiveConnection = Nothing
Exit_Update_Assign_Click:
Exit Function
Err_Update_Assign_Click:
MsgBox Err.Description
Resume Exit_Update_Assign_Click
End Function
that fires a macro to run the code below… however…
I keep getting
[Microsoft] [ODBC Driver Manager] Data source name not found and no default
driver specified
I believe I have everything as far as Access installed correctly…
Is there a problem with my code?
Public Function Update_Assign() As String
'Error Handling
On Error GoTo Err_Update_Assign_Click
'Establish
Dim allRecords As ADODB.Recordset
Dim cnCh5 As ADODB.Connection
Dim strConnection As String
Dim cmdCommand As ADODB.Command
Set cmdCommand = New ADODB.Command
Dim MySQL As String
Set cnCh5 = New ADODB.Connection
cnCh5.Open strConnection
Dim prompt, buttons, title
Dim Doc_Type As Integer
Doc_Type = Forms!Assignment_frm!Type_ID
Dim Buyer As Integer
Buyer=Forms!Assignment_frm!Assign_Buyer
Dim C_Date As Date
C_Date = Date
Dim Comments As String
If IsNull(Forms!Assignment_frm!Comments.Value) = True Then
Comments = "N / A"
Else
Comments = Forms!Assignment_frm!Comments
End If
MySQL = "INSERT INTO Assignment_History(Type_ID, Doc_ID, Buyer,
Assigned_Date, Comments) " & _
"VALUES (" & _
"'" & Doc_Type & "', " & _
"'" & Doc_No & "', " & _
"'" & Buyer & "', " & _
"'" & C_Date & "', " & _
"'" & Comments & "', "
prompt = "Assignment History updated."
buttons = vbOKOnly
title = "Notification"
Update_Assign = MsgBox(prompt, buttons, title)
Set cmdCommand.ActiveConnection = cnCh5
'set the SQL statement to the command text
cmdCommand.CommandText = MySQL
'execute command
cmdCommand.Execute
Set allRecords.ActiveConnection = cnCh5
allRecords.Requery
Set allRecords.ActiveConnection = Nothing
Exit_Update_Assign_Click:
Exit Function
Err_Update_Assign_Click:
MsgBox Err.Description
Resume Exit_Update_Assign_Click
End Function