Acet1485
Programmer
- Aug 10, 2011
- 2
Before I begin, I would like to thank any and all even willing to take a gander at my dilemma. I am pretty new at using Access, and was given the task of creating a new database for my office. The project has run smoothly up until now.
I have a form (frmTicketView)that retrieves and displays specific records from the table (tblTicket_Requests). The form allows the user to update 2 fields in particular, (Ticket_Status) and (Date_Closed) by clicking an update button on the bottom of the form that opens up a new form with 2 unbound fields that represent these two controls. This code has been used in the same manner to update data in another of my tables. The only difference is that table had an AutoID with the Autonumber field type. This table however, uses a text field (Ticket_No. My aplogies for the wall of text, but here is the code.
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim db As DAO.Database
Dim rst As DAO.Recordset
strMessage = "Update this Ticket?"
intOptions = vbQuestion + vbYesNo
bytchoice = MsgBox(strMessage, intOptions)
If bytchoice = vbYes Then
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT * FROM (tblTicket_Requests) Where (Ticket_No) =" & Forms!frmTicketView.Ticket_No, dbOpenDynaset, dbSeeChanges)
With rst
.Edit
!Date_Completed = Forms!frmTicketUpdate![Text0]
!Ticket_Status = Forms!frmTicketUpdate![Combo5]
.Update
.Close
End With
MsgBox ("Ticket Updated!")
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
End If
End Sub
I tried for 2 full days now to figure out why my SELECT statement fails in VBA but works in query design. Any help would be greatly appreciated.
I have a form (frmTicketView)that retrieves and displays specific records from the table (tblTicket_Requests). The form allows the user to update 2 fields in particular, (Ticket_Status) and (Date_Closed) by clicking an update button on the bottom of the form that opens up a new form with 2 unbound fields that represent these two controls. This code has been used in the same manner to update data in another of my tables. The only difference is that table had an AutoID with the Autonumber field type. This table however, uses a text field (Ticket_No. My aplogies for the wall of text, but here is the code.
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim db As DAO.Database
Dim rst As DAO.Recordset
strMessage = "Update this Ticket?"
intOptions = vbQuestion + vbYesNo
bytchoice = MsgBox(strMessage, intOptions)
If bytchoice = vbYes Then
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT * FROM (tblTicket_Requests) Where (Ticket_No) =" & Forms!frmTicketView.Ticket_No, dbOpenDynaset, dbSeeChanges)
With rst
.Edit
!Date_Completed = Forms!frmTicketUpdate![Text0]
!Ticket_Status = Forms!frmTicketUpdate![Combo5]
.Update
.Close
End With
MsgBox ("Ticket Updated!")
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
End If
End Sub
I tried for 2 full days now to figure out why my SELECT statement fails in VBA but works in query design. Any help would be greatly appreciated.