'Database' set 0 field(s) to Null due to a type conversion failure, and it didn't add 1 record(s) to the table due to key violations....etc
what i wanted to do was grab the autonumber (aka Trouble #) along with the date, username, and the string "Ticket Created" and insert it into the table.
my previous problem as discussed in this thread http://bytes.com/topic/access/answer...-sql-statement has been solved already with the use of [ ] around date.
I have the following code for a new record
Expand|Select|Wrap|Line Numbers
- Private Sub Command67_Click()
- On Error GoTo Err_Command67_Click
- DoCmd.GoToRecord , , acNewRec
- 'Setting the open date to current date
- date_opened = date
- Call sqlstatement2("Ticket Created")
- 'Setting the Ticket Status to Open
- Combo46 = "OPEN"
- [Forms]![User Problem Log]![Opened_By] = user_name
- Me!user.SetFocus
- If IsNull(user) Then
- Command67.Enabled = False
- 'disables the add button if end user is not selected.
- 'this is to prevent user from accidentally clicking add
- 'button twice which creates two new records.
- Else
- Command67.Enabled = True 'enable the add button
- End If
- Exit_Command67_Click:
- Exit Sub
- Err_Command67_Click:
- MsgBox Err.Description
- Resume Exit_Command67_Click
- End Sub
trouble_no is a number field
date is a date/time field
user is a string field
notes is a memo field
Expand|Select|Wrap|Line Numbers
- Sub sqlstatement2(status As String)
- Dim strSQL As String
- strSQL = "INSERT INTO usr_problem_list "
- strSQL = strSQL & "(trouble_no, [date], user, notes) "
- strSQL = strSQL & "VALUES (" & Text30.Value & ", '" & Now() & "', '" & user_name & "', '" & status & "');"
- DoCmd.RunSQL strSQL
Expand|Select|Wrap|Line Numbers
- Private Sub Form_Load()
- '********** Setting the form to load waiting for a new ticket to be entered **********
- On Error GoTo Err_Command21_Click
- DoCmd.GoToRecord , , acNewRec
- If IsNull(Text30) Then
- Command58.Enabled = False
- End If
- Exit_Command21_Click:
- Exit Sub
- Err_Command21_Click:
- MsgBox Err.Description
- Resume Exit_Command21_Click
- '********** Setting the form to load waiting for a new ticket to be entered **********
- End Sub