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



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]", _

MsgBox strMessage, vbOKOnly, "Errors Occurred"
End If

Exit Sub

MsgBox Err.Description
Resume Exit_AddSpec_cmd_Click:

Steve Sanford

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).


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question