ibs001
asked on
Form in add mode
If i use below code i get by clicking on a form all the records. But i want to get the form in add mode, now i get in my last question the advice to use the code:
DoCmd.OpenForm "Opdrachtbevestiging", , , , acFormAdd
But where in the below code code do i have to insert or replace this??
Private Sub Klantcontact_Click()
On Error GoTo Err_Klantcontact_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Klantcontact"
If IsNull(Me![IDBedrijf]) Then
MsgBox "Eerst klantgegevens invoeren alvorens een klantcontact in te voeren"
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm stDocName
Form_Klantcontact.DataEntr y = True
Form_Klantcontact.AllowAdd itions = True
'Form_Opdrachtbevestiging. AllowEdits = False
'Form_Opdrachtbevestiging. AllowEdits = True
End If
IDBedrijfK = Me![IDBedrijf]
stLinkCriteria = "[IDBedrijf]=" & Me![IDBedrijf]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Klantcontact_Click:
Exit Sub
Err_Klantcontact_Click:
MsgBox Err.Description
Resume Exit_Klantcontact_Click
End Sub
DoCmd.OpenForm "Opdrachtbevestiging", , , , acFormAdd
But where in the below code code do i have to insert or replace this??
Private Sub Klantcontact_Click()
On Error GoTo Err_Klantcontact_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Klantcontact"
If IsNull(Me![IDBedrijf]) Then
MsgBox "Eerst klantgegevens invoeren alvorens een klantcontact in te voeren"
Else
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm stDocName
Form_Klantcontact.DataEntr
Form_Klantcontact.AllowAdd
'Form_Opdrachtbevestiging.
'Form_Opdrachtbevestiging.
End If
IDBedrijfK = Me![IDBedrijf]
stLinkCriteria = "[IDBedrijf]=" & Me![IDBedrijf]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Klantcontact_Click:
Exit Sub
Err_Klantcontact_Click:
MsgBox Err.Description
Resume Exit_Klantcontact_Click
End Sub
ASKER
Nico, thanks for your advice. But isn't it possible to change something in my code, otherwise i get three buttons instead of one.
And i don't have to have a update button, but only a add one with a link criteria on IDBedrijf.
And i don't have to have a update button, but only a add one with a link criteria on IDBedrijf.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would probably split this code and do some redesign.
1) I would create a Save button that will check or everything has been filled.
2) I would create a "Nieuw KlantContact" button that's by default disabled. After selecting a "bedrijf" e.g. with a combobox, the button can be enabled.
3) I would create a separate Update and Add button for the "bedrijf".
Again the Update button will be disabled when no "bedrijf" has been specified.
BTW I guess the message should read:
"Eerst bedrijf invullen alvorens een klantcontact in te voeren"
But using my approach you don't need this anymore...
Getting the idea ?
Nic;o)