Paul Cooke
Registered User.
- Local time
- Today, 16:46
- Joined
- Oct 12, 2001
- Messages
- 288
Hi Guys,
I have a form that on completion needs to ask the user a couple of questions to determine where the process goes.
I am getting a bit confused with how to write the responses and hopefully someone can guide me in the right direction. The code I have at the moment is as below...
(Sorry that its not tabbed out properly - work in progress!)
I have read a bit about the 'Else if' statement but never used it before and not sure if this can apply to my case? If it does how would I use it?
hopefully this makes sense !
Thanks for any advice offered.
I have a form that on completion needs to ask the user a couple of questions to determine where the process goes.
I am getting a bit confused with how to write the responses and hopefully someone can guide me in the right direction. The code I have at the moment is as below...
Code:
Private Sub cboStaffName_AfterUpdate()
'Questions following entry to the form after entering the staff name
If Me.Dirty = True Then
'Automatically updates the Treatment Reference number by 1
If Me.OpenArgs = "AddMode" Then
lngTrNum = lngTrNum + 1
Set rs = CurrentDb.OpenRecordset("ReferenceNumbers")
rs.Edit
rs.Fields("NextTreatmentNumber").Value = lngTrNum
rs.Update
rs.Close
Set rs = Nothing
End If
Me.Dirty = False
End If
Beep
MsgResponse = MsgBox("Was this treatment required as as a result of an accident?", vbQuestion + vbYesNo, "Accident")
If MsgResponse = vbNo Then
Beep
MsgResponse1 = MsgBox("Were any consumables used to treat the patient?", vbQuestion + vbYesNo, "Comsumables")
If MsgResponse1 = vbYes Then
lngTrNum = Me.txtTreatmentID
DoCmd.OpenForm "Consumables", , , "TreatmentID = " & lngTrNum & ""
DoCmd.Close acForm, "FindPatientTreatment"
Else
DoCmd.Close acForm, "Consumables"
DoCmd.Close acForm, "NewTreatment"
DoCmd.Close acForm, "FindPatientTreatment"
DoCmd.OpenForm "Navigation"
If MsgResponse = vbYes Then
Beep
MsgResponse2 = MsgBox("Does the patient wish to complete an accident form?" _
, vbQuestion + vbYesNo, "Accident")
If MsgResponse2 = vbYes Then
lngTrNum = Me.txtTreatmentID
DoCmd.OpenForm "Consumables", , , "TreatmentID = " & lngTrNum & "", , acHidden
DoCmd.OpenForm "Accident", , , , acFormAdd, , "Treatment"
Else
Me.tckAccidentRefusal = True
Beep
MsgResponse3 = MsgBox("Were any consumables used to treat the patient?", vbQuestion + vbYesNo, "Comsumables")
If MsgResponse3 = vbYes Then
lngTrNum = Me.txtTreatmentID
DoCmd.OpenForm "Consumables", , , "TreatmentID = " & lngTrNum & ""
DoCmd.Close acForm, "FindPatientTreatment"
Else
DoCmd.Close acForm, "Consumables"
DoCmd.Close acForm, "NewTreatment"
DoCmd.Close acForm, "FindPatientTreatment"
DoCmd.OpenForm "Navigation"
End If
End If
End If
End If
End If
End Sub
I have read a bit about the 'Else if' statement but never used it before and not sure if this can apply to my case? If it does how would I use it?
hopefully this makes sense !
Thanks for any advice offered.