If, then function....

spikey

New member
Local time
Today, 07:26
Joined
Jan 27, 2004
Messages
9
Hi,

I'm having some problems with this function. In the following pieces of code, the function doesn't work properly:

-------------------------------
Private Sub Command26_Click()

MsgBox "Zijn alle verplichte velden ingevoerd?", vbOKCancel

If vbCancel Then

Else

DoCmd.OpenForm "bachelor_alumnus_invoer"
DoCmd.Close acForm, "Subadres_Bachelor_invoer"

End If

End Sub
-------------------------------------------------

I want to stop the execution (so stay in the same form, Subadres_......) if the user presses the cancel button in the dialog box. But if the user presses "ok" nothing happens..

The same problem here:

--------------------------------------------------

Private Sub Command26_Click()
On Error GoTo Err_Command26_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

If me.[naam] ="null" then

DoCmd.close

Else

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Hulpform_BsC_adres"

stLinkCriteria = "[AlumnusID]=" & Me![AlumnusID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

stDocName = "Hulpform_BsC_functie"

stLinkCriteria = "[AlumnusID]=" & Me![AlumnusID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

stDocName = "Hulpform_BsC_opleiding"

stLinkCriteria = "[AlumnusID]=" & Me![AlumnusID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

stDocName = "Hulpform_BsC_foto"

stLinkCriteria = "[AlumnusID]=" & Me![AlumnusID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close

End if

Exit_Command26_Click:
Exit Sub

Err_Command26_Click:
MsgBox Err.Description
Resume Exit_Command26_Click

End Sub
--------------------------------------------------

Im not a programmer so i don't know where to look for solutions, hope someone can help me.

Thnx Spikey
 
Private Sub Command26_Click()

if MsgBox("Zijn alle verplichte velden ingevoerd?", vbOKCancel) = 2 Then
exit sub
Else
DoCmd.OpenForm "bachelor_alumnus_invoer"
DoCmd.Close acForm, "Subadres_Bachelor_invoer"
End If

End Sub


???
ken
 
Spikey -

Jus so you know in Ken's example above the "2" is another way of saying "cancel"... the line could also be written like this:

if MsgBox("Zijn alle verplichte velden ingevoerd?", vbOKCancel) = vbCancel Then
....


HTH,
Kev
 
thnx, but..

This one works, thnx but i still don't see what i'm doing wrong in the second piece of code...
 
It looks like the argument me.[name]="null" doens't work. The goal is that if that field isn't entered the form closes itsself without running the other part of the code..
 

Users who are viewing this thread

Back
Top Bottom