Having some real difficulty with this code which is essentially 3 parts that I am trying to combine
Private Sub cmdAddNewEquip_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Dim x As Integer
x = MsgBox("Are you sure you want to save changes?", 4, "Exit?")
'VbNo constant throws back #7
'VbYes constant throws back #6
If x = 7 Then
Exit Sub
Else
If Me.[cmbEquipType].Value = "1" Then
DoCmd.OpenForm "frmEquip1"
Else
Me.[cmbEquipType].SetFocus
End If
If Me.[cmbEquipType].Value = "2" Then
DoCmd.OpenForm "frmEquip2"
Else
Me.[cmbEquipType].SetFocus
End If
db.Execute " INSERT INTO [tblEquipmentInspectionJunction]" & "([EquipmentID], [InspectionID]) VALUES " _
& "('" & Me.Controls("txtEquipment").Value & "'," & "'" & Me.Controls("txtInspection").Value & "'" & ");"
DoCmd.Close
End If
End Sub
The first part is asking whether you want to save changes and then should save to table and close form, the second part chooses the form to open dependent on the combo box selection and the 3rd part enters values in another table.
I have tried in all different orders and arrangements to try and combine and cannot get all 3 things working in one sub. they all work fine in separate subs but I want to combine them
Thanks for your help