validating input of textbox before publishing

  • Thread starter Thread starter eyesonly1965
  • Start date Start date
E

eyesonly1965

hello,

in my form i have some textboxes that need input, now i want to
validate those boxes before i publish my form into a sheet.

can anyone tell me how to do this?

in this part of my form i need to validate (see code)

-Private Sub cmdOk_Click()

'Gegevens naar invultab plaatsen om
'ze vervolgens door te linken naar het cmr blad
ActiveWorkbook.Sheets("Invultab").Activate
Range("A1").Select
ActiveCell.Value = txtKlantNaam.Value

'met de functie offset verplaats je de active cell
'of een stap naar rechts of naar beneden
ActiveCell.Offset(0, 1) = txtKlantAdres.Value
ActiveCell.Offset(0, 2) = txtKlantPostcode.Value
ActiveCell.Offset(0, 3) = txtKlantPlaats.Value
ActiveCell.Offset(0, 4) = txtKlantLand.Value
ActiveCell.Offset(0, 5) = cboVervoerder.Value
ActiveCell.Offset(0, 6) = txtOrdernummer1.Value
ActiveCell.Offset(0, 7) = txtcolli1.Value
ActiveCell.Offset(0, 8) = cboColliOmschrijving1.Value
ActiveCell.Offset(0, 9) = txtOrdernummer2.Value
ActiveCell.Offset(0, 10) = txtcolli2.Value
ActiveCell.Offset(0, 11) = cboColliOmschrijving2.Value
ActiveCell.Offset(0, 12) = txtOrdernummer3.Value
ActiveCell.Offset(0, 13) = txtcolli3.Value
ActiveCell.Offset(0, 14) = cboColliOmschrijving3.Value
ActiveCell.Offset(0, 15) = txtOrdernummer4.Value
ActiveCell.Offset(0, 16) = txtcolli4.Value
ActiveCell.Offset(0, 17) = cboColliOmschrijving4.Value
ActiveCell.Offset(0, 18) = txtOrdernummer5.Value
ActiveCell.Offset(0, 19) = txtcolli5.Value
ActiveCell.Offset(0, 20) = cboColliOmschrijving5.Value
ActiveCell.Offset(0, 21) = txtOrdernummer6.Value
ActiveCell.Offset(0, 22) = txtcolli6.Value
ActiveCell.Offset(0, 23) = cboColliOmschrijving6.Value
ActiveCell.Offset(0, 24) = txtOpmerking1.Value
ActiveCell.Offset(0, 25) = txtOpmerking2.Value

'in de volgende if functie wordt gekeken welke optie
'is geselecteerd en geeft deze dan de waarde x
If optFranco = True Then
ActiveCell.Offset(0, 26).Value = "x"
ElseIf optNietFranco = True Then
ActiveCell.Offset(0, 27).Value = "x"
End If

Range("A1").Select




End Sub-
 
Can you give a example

Numeric validation or test if there is text in the textbox

Groeten Ron
 
i need to validate if there is something in the textboxes, for some
there are numeric values and others have a text value.
but that is not important to me it is just that some of the fields need
an input and this is what i want to check
 
Try this

Private Sub CommandButton1_Click()
If Trim(Me.TextBox1.Text) = "" Or Trim(Me.TextBox2.Text) = "" Then
MsgBox "Enter info in the textboxes please"
Else
'Your code
End If
End Sub
 
thank you very much for youre help.

with that little piece of code i made it work.
just a little adjustment and it did exactly what i wanted.

see code below how i did it now.

-Private Sub cmdOk_Click()

'het volgende stukje code dient ervoor om te controleren
'of de verplichte velden zijn ingevult
If Trim(Me.txtKlantNaam.Text) = "" Then
MsgBox "De klant naam is een verplicht veld, dus dient deze te
worden ingevuld"

ElseIf Trim(Me.txtKlantAdres.Text) = "" Then
MsgBox "Het Adres van de klant is een verplicht veld en
dient te worden ingevuld"

ElseIf Trim(Me.txtKlantPostcode.Text) = "" Then
MsgBox "De Postcode van de Klant is niet Ingevult, maar is
wel verplicht"

ElseIf Trim(Me.txtKlantPlaats.Text) = "" Then
MsgBox "vul de plaatsnaam van de klant in"

ElseIf Trim(Me.txtKlantLand.Text) = "" Then
MsgBox "het land van de klant dient nog te worden
ingevuld"

ElseIf Trim(Me.cboVervoerder.Text) = "" Then
MsgBox "vul de vervoerder in"

ElseIf Trim(Me.txtOrdernummer1.Text) = "" Then
MsgBox "eerste ordernummer dient te worden ingevoerd"

ElseIf Trim(Me.txtcolli1.Text) = "" Then
MsgBox "aantal colli van de eerste zending dient ingevult
te worden"

ElseIf Trim(Me.cboColliOmschrijving1.Text) = "" Then
MsgBox "voor de eerste zending dient de colli omschrijving
nog ingevult te worden"

Else




'Gegevens naar invultab plaatsen om
'ze vervolgens door te linken naar het cmr blad
ActiveWorkbook.Sheets("Invultab").Activate
Range("A1").Select
ActiveCell.Value = txtKlantNaam.Value

'met de functie offset verplaats je de active cell
'of een stap naar rechts of naar beneden
ActiveCell.Offset(0, 1) = txtKlantAdres.Value
ActiveCell.Offset(0, 2) = txtKlantPostcode.Value
ActiveCell.Offset(0, 3) = txtKlantPlaats.Value
ActiveCell.Offset(0, 4) = txtKlantLand.Value
ActiveCell.Offset(0, 5) = cboVervoerder.Value
ActiveCell.Offset(0, 6) = txtOrdernummer1.Value
ActiveCell.Offset(0, 7) = txtcolli1.Value
ActiveCell.Offset(0, 8) = cboColliOmschrijving1.Value
ActiveCell.Offset(0, 9) = txtOrdernummer2.Value
ActiveCell.Offset(0, 10) = txtcolli2.Value
ActiveCell.Offset(0, 11) = cboColliOmschrijving2.Value
ActiveCell.Offset(0, 12) = txtOrdernummer3.Value
ActiveCell.Offset(0, 13) = txtcolli3.Value
ActiveCell.Offset(0, 14) = cboColliOmschrijving3.Value
ActiveCell.Offset(0, 15) = txtOrdernummer4.Value
ActiveCell.Offset(0, 16) = txtcolli4.Value
ActiveCell.Offset(0, 17) = cboColliOmschrijving4.Value
ActiveCell.Offset(0, 18) = txtOrdernummer5.Value
ActiveCell.Offset(0, 19) = txtcolli5.Value
ActiveCell.Offset(0, 20) = cboColliOmschrijving5.Value
ActiveCell.Offset(0, 21) = txtOrdernummer6.Value
ActiveCell.Offset(0, 22) = txtcolli6.Value
ActiveCell.Offset(0, 23) = cboColliOmschrijving6.Value
ActiveCell.Offset(0, 24) = txtOpmerking1.Value
ActiveCell.Offset(0, 25) = txtOpmerking2.Value

'in de volgende if functie wordt gekeken welke optie
'is geselecteerd en geeft deze dan de waarde x
If optFranco = True Then
ActiveCell.Offset(0, 26).Value = "x"
ElseIf optNietFranco = True Then
ActiveCell.Offset(0, 27).Value = "x"
End If

Range("A1").Select

End If


End Sub-
 
Back
Top