Update Query not running from Button

Local time
Yesterday, 18:19
Joined
Jul 29, 2005
Messages
62
Hi Folks,

I'm sure this is a very quick question, with an obvious answer but looking on the forum I can't find it.

I have a button that on click sends out meeting requests, I also have an update query that ticks a box to say the email has been sent "UPD_WaitingList_Added" what I've tried to do is just add a bit of code to the bottom of the code for the button to run this query, but nothing seems to happen (the query works perfectly if I run it manually. My code is below and the part in red is what I've added...
...I've also tried docmd.openquery "UPD_WaitingList_Added"

Any ideas?:confused:

Private Sub Command21_Click()


' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
' Provide warning if meeting request already sent.
If Me!ReqSent = True Then
MsgBox "A meeting request has already ben issued"



' Add a new meeting.
Else
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Set outobj = CreateObject("outlook.Application")
Set outappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = [txtCourseDate] & " 09:00"
.Duration = [txtDuration]
.Subject = [txtSubject]
.MeetingStatus = olMeeting
Set myRequiredAttendee = .Recipients.Add(Me!txtMail)
myRequiredAttendee.Type = olRequired
If Not IsNull("test") Then .Body = [txtBody]
If Not IsNull("BDU") Then .Location = _
"BDU"
.Recipients.ResolveAll
.Display
.Send
.Save
End With
End If
' Release the Outlook object variable.
Set outobj = Nothing
' Set the AddedToOutlook flag, save the record, display a message.
Me!ReqSent = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description

DoCmd.SetWarnings False
Me.Refresh
CurrentDb.Execute "UPD_WaitingList_Added"
DoCmd.SetWarnings True

Exit Sub
End Sub
 
I have no idea, but maybe you should post the query that's not working so we can have a look at it.

If you can't get it working, maybe try running it from VBA.
 

Users who are viewing this thread

Back
Top Bottom