Cmd button --- check the values first,append record and then delete them.

  • Thread starter Thread starter New_Access
  • Start date Start date
N

New_Access

I think there's onething strange from below code.
The code is not work just in once click.
And in addition we have we have to move to the
next record field first so that the command can be
progressed but it means there is a blank second
record is appended.Why?Please help.



Private Sub AddSpec_cmd_Click()
On Error GoTo Err_AddSpec_cmd_Click

Dim db As Database
Dim strMessage As String

If IsNull(Me.Model) Then
strMessage = strMessage & _
" Enter Model Name" & vbCrLf
End If

If Inputvoltage.Value < 11 Then
strMessage = strMessage & _
" Input correct voltage rate " & vbCrLf
End If

If Len(strMessage) = 0 Then
Set db = CurrentDb
db.Execute "Appendix model spec_qry", dbFailOnError
CurrentDb.Execute "DELETE * FROM [Appendix model specification_tbl]", _
dbFailOnError

Else
MsgBox strMessage, vbOKOnly, "Errors Occurred"
End If

Exit_AddSpec_cmd_Click:
Exit Sub

Err_AddSpec_cmd_Click:
MsgBox Err.Description
Resume Exit_AddSpec_cmd_Click:
 
In this line

db.Execute "Appendix model spec_qry", dbFailOnError

"Appendix model spec_qry" is not valid SQL action query syntax.



The SQL string must start with Append", "Update", "Delete" or "Select Into"
(a make table query).

HTH
 
Back
Top