Heb Middels jullie forum gezocht hoe ik kan terugkeren naar een verplicht veld in mijn formulier dat niet is ingevuld, echter na klikken op OK gaat de cursor niet naar veld TxtNaam, maar gaat door naar de mailbox en zet het formulier gereed voor verzending. Waarom gaat de cursor niet terug naar het tekstveld?
Private Sub CommandButton1_Click()
If TxtNaam = "" Then
response = MsgBox("U dient een naam in te voeren", 0, "")
End If
If reponse = "0" Then
TxtNaam.SetFocus
End If
'Updated by Extendoffice 2017/9/14
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
ActiveWorkbook.Save
xMailBody = "Beste collega's, " & vbNewLine & _
"" & vbNewLine & _
"Gelieve deze bestelling te plaatsen." & vbNewLine & _
"" & vbNewLine & _
"Met vriendelijke groet,"
On Error Resume Next
With xOutMail
.to = "bestellingen@humankind.nl"
.CC = "facilitydesk@humankind.nl"
.BCC = ""
.Subject = "Bestelling voor Facility"
.Body = xMailBody
.Attachments.Add ActiveWorkbook.FullName
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Private Sub CommandButton1_Click()
If TxtNaam = "" Then
response = MsgBox("U dient een naam in te voeren", 0, "")
End If
If reponse = "0" Then
TxtNaam.SetFocus
End If
'Updated by Extendoffice 2017/9/14
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
ActiveWorkbook.Save
xMailBody = "Beste collega's, " & vbNewLine & _
"" & vbNewLine & _
"Gelieve deze bestelling te plaatsen." & vbNewLine & _
"" & vbNewLine & _
"Met vriendelijke groet,"
On Error Resume Next
With xOutMail
.to = "bestellingen@humankind.nl"
.CC = "facilitydesk@humankind.nl"
.BCC = ""
.Subject = "Bestelling voor Facility"
.Body = xMailBody
.Attachments.Add ActiveWorkbook.FullName
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub