I have a form and it is to creat a 'link' between a project and a company. Creating a record form this table will simply create a record in a databse with the company ID and project ID. Project ID is selected form a drop down bax and Company ID is selected from a combo box. I am trying to create a script that if you click exit form, and one or the other, or both of the fields have a selection it will bring up message box and inform the user of the situation, and what will happen. That i am not having trouble with. I am having trouble with the Docmd.close! it seems that this command creates a new record, even when the
DoCmd.GoToRecord , , acNewRec command is not there. The form is set as a data entry form. I have included my if statements but i dont think the problem is there. I have taken out the close commands and records are not created, i put them back in and the form closes and creates the record. How do i close the form without it creating the record.
P.S. i have also tried doCmd.close as upposed to coCmd.close acForm, "form_Company-Project" with the same record creating result.
Any help would be greatly appreciated
Cheers,
Oxford Consult
-
Private Sub Command22_Click()
-
-
If Me.Combo25.Value = 0 Then
-
If Me.Combo8.Value = 0 Then
-
DoCmd.Close acForm, "Form_Company-Project"
-
DoCmd.OpenForm "Form_Mainpage"
-
Else
-
MsgBox "You have only selected a company and no link will be created", vbCritical, "Note"
-
DoCmd.Close
-
DoCmd.OpenForm "Form_Mainpage"
-
End If
-
Else
-
If Me.Combo8.Value = 0 Then
-
MsgBox "You have only selected a project and no link will be created", vbCritical, "Note"
-
DoCmd.Close acForm, "Form_Company-Project"
-
DoCmd.OpenForm "Form_Mainpage"
-
Else
-
zmessage = MsgBox("You have slected a company and project to create a link but have not created a link." & vbCrLf _
-
& "Do you wish to do so now?", vbYesNo + vbQuestion, "Link selected but not created")
-
If zmessage = 6 Then
-
MsgBox ""
-
MsgBox "A link has been created", vbInformation, "Note"
-
DoCmd.Close acForm, "Form_Company-Project"
-
DoCmd.OpenForm "Form_Mainpage"
-
Else
-
DoCmd.Close acForm, "Form_Company-Project"
-
DoCmd.OpenForm "Form_Mainpage"
-
End If
-
End If
-
End If
-
-
End Sub
-