value of textbox not showing in userform

pascal2be

New Member
Joined
Apr 28, 2020
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
i'm new at VBA and have a userform that i'm making to keep track of some data. The userform has an textbox that autogenerates an number and that number should be show in a msgbox but doesn't. What can be the issue? What do i have to check? Other txtbox work just fine only txtbox with autonumber doesn't.

thanks for any feedback
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
VBA Code:
Private Sub CmdBewaren_Click()

    Dim msgValue As VbMsgBoxResult
    Dim txtVoorbeeld As String

    msgValue = MsgBox("Wil je de data bewaren?", vbYesNo + vbInformation, "Bevestiging")

    If msgValue = vbNo Then Exit Sub
   
    '' controle of alle verplichte info voorzien is
   
    If Validatie() = True Then
   
   
    '' info text creatie intern nummering LCCU na validatie
   
    Me.txtVoorbeeld.Value = Me.txtRowNumber & "/" & Year(Date) & "/" & Me.cmbTeam & "/" & Me.txtSoort & Me.txtType & Me.txtDossiernaam & Me.txtEigenaar
   
    ''msgbox voor testing
   
    msgValue = MsgBox(Me.txtRowNumber.Value, vbOKOnly + vbInformation, "nummer")
       
    Call submit
          
    Call Reset

    End If

End Sub

Private Sub CmdReset_Click()

    Dim msgValue As VbMsgBoxResult

    msgValue = MsgBox("Wil je het formulier resetten?", vbYesNo + vbInformation, "Bevestiging")

    If msgValue = vbNo Then Exit Sub

    Call Reset

End Sub

Private Sub CmdEdit_Click()

    If Selected_list = 0 Then
   
        MsgBox " Geen selectie gemaakt.", vbOKOnly + vbInformation, "Edit"
        Exit Sub
       
    End If
   
   Dim sStavaza As String
   
       
    Me.txtRowNumber.Value = Selected_list + 1
   
     
    Me.cmbType.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 1)
   
    sStavaza = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 2)
   
    If sStavaza = "OUT" Then
   
        Me.OptOut.Value = True
            
    Else
   
        Me.OptIn.Value = True
              
       
    End If
   
    Me.cmbTeam.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 3)
   
    Me.txtContactpersoon.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 4)
   
    Me.txtTelefoon.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 5)
   
    Me.txtAPV.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 6)
   
    Me.txtDossier.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 7)
    Me.txtNaam.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 8)
    Me.txtKantschrift.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 9)
    Me.txtDossiernaam.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 10)
    Me.txtGES.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 11)
    Me.txtSoort.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 12)
    Me.txtMerk.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 13)
    Me.txtType.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 14)
    Me.txtIMEI.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 15)
    Me.txtBeveliging.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 16)
    Me.txtPin.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 17)
    Me.txtEigenaar.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 18)
    Me.txtOproepnummer.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 19)
    Me.txtAanvrager.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 20)
    Me.txtUitlezing.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 21)
    Me.txtUitgevoerd.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 22)
    Me.txtLCCU.Value = Me.LstDatabase.List(Me.LstDatabase.ListIndex, 23)
   
   
    MsgBox "Maak de nodige aanpassingen en klik 'bewaren' om te updaten.", vbOKOnly + vbInformation, "Edit"
   
   
   
End Sub



Private Sub userform_initialize()

    Call Reset
   
End Sub
Option Explicit


Sub Reset()

    Dim iRow As Long

    iRow = [Counta(Database!A:A)] 'herkennen laatste rij

    With frmForm 'formulier tonen

        .txtAanvrager = ""
        .txtAPV = ""
        .txtBeveliging = ""
        .txtContactpersoon = ""
        .txtDossier = ""
        .txtDossiernaam = ""
        .txtEigenaar = ""
        .txtGES = ""
        .txtIMEI = ""
        .txtKantschrift = ""
        .txtLCCU = ""
        .txtMerk = ""
        .txtNaam = ""
        .txtOproepnummer = ""
        .txtPin = ""
        .txtSoort = ""
        .txtTelefoon = ""
        .txtType = ""
        .txtUitgevoerd = ""
        .txtUitlezing = ""
        .OptIn = False
        .OptOut = False
       
        .cmbTeam.Clear 'lijst maken teams
               
        .cmbTeam.AddItem "Bijz.Crim"
        .cmbTeam.AddItem "COPPRA"
        .cmbTeam.AddItem "Diefstallen"
        .cmbTeam.AddItem "Drugs"
        .cmbTeam.AddItem "Ecofin"
        .cmbTeam.AddItem "Gauwdiefstallen"
        .cmbTeam.AddItem "Geweld"
        .cmbTeam.AddItem "GO"
        .cmbTeam.AddItem "Jongerencrim"
        .cmbTeam.AddItem "Meprosch"
        .cmbTeam.AddItem "Runners"
        .cmbTeam.AddItem "TST"
        .cmbTeam.AddItem "Verdwijningen"
        .cmbTeam.AddItem "Zeden"
        .cmbTeam.AddItem "ID"
        .cmbTeam.AddItem "WD"
        .cmbTeam.AddItem "Andere"
       
       
        .cmbType.Clear 'lijst maken type
       
        .cmbType.AddItem "Computer"
        .cmbType.AddItem "Cybercrime"
        .cmbType.AddItem "Mercure"
        .cmbType.AddItem "Mobile"
        .cmbType.AddItem "Netwerkzoeking"
        .cmbType.AddItem "OSINT"
        .cmbType.AddItem "Andere"
       
       
        .txtRowNumber.Value = ""
       
       
        .LstDatabase.ColumnCount = 24
        .LstDatabase.ColumnHeads = True
        .LstDatabase.ColumnWidths = "45,60,20,40,60,45,55,70,70,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60"
       
        If iRow > 1 Then
       
            .LstDatabase.RowSource = "database!A2:X" & iRow
           
        Else
       
            .LstDatabase.RowSource = "database!A2:X2"
           
        End If
       
       
           
    End With

End Sub

Sub submit()

    Dim sh As Worksheet
    Dim iRow As Long
   
    Set sh = ThisWorkbook.Sheets("Database")
   
    If frmForm.txtRowNumber.Value = "" Then
   
        iRow = [Counta(Database!A:A)] + 1
    Else
        iRow = frmForm.txtRowNumber.Value
       
    End If
   
    With sh
   
        .Cells(iRow, 1) = iRow - 1
        .Cells(iRow, 1).NumberFormat = "LCCU000"
        .Cells(iRow, 2) = frmForm.cmbType.Value
        .Cells(iRow, 3) = IIf(frmForm.OptOut.Value = True, "Out", "IN")
        .Cells(iRow, 4) = frmForm.cmbTeam.Value
        .Cells(iRow, 5) = frmForm.txtContactpersoon
        .Cells(iRow, 6) = frmForm.txtTelefoon
        .Cells(iRow, 7) = frmForm.txtAPV
        .Cells(iRow, 8) = frmForm.txtDossier
        .Cells(iRow, 9) = frmForm.txtNaam
        .Cells(iRow, 10) = frmForm.txtKantschrift
        .Cells(iRow, 11) = frmForm.txtDossiernaam
        .Cells(iRow, 12) = frmForm.txtGES
        .Cells(iRow, 13) = frmForm.txtSoort
        .Cells(iRow, 14) = frmForm.txtMerk
        .Cells(iRow, 15) = frmForm.txtType
        .Cells(iRow, 16) = frmForm.txtIMEI
        .Cells(iRow, 17) = frmForm.txtBeveliging
        .Cells(iRow, 18) = frmForm.txtPin
        .Cells(iRow, 19) = frmForm.txtEigenaar
        .Cells(iRow, 20) = frmForm.txtOproepnummer
        .Cells(iRow, 11) = frmForm.txtAanvrager
        .Cells(iRow, 22) = frmForm.txtUitlezing
        .Cells(iRow, 23) = frmForm.txtUitgevoerd
        .Cells(iRow, 24) = frmForm.txtLCCU
       
       
    End With
   
       
End Sub

Sub Show_Form()

    frmForm.Show

End Sub

Function Selected_list() As Long

    Dim i As Long

    Selected_list = 0
    For i = 0 To frmForm.LstDatabase.ListCount - 1
        If frmForm.LstDatabase.Selected(i) = True Then
            Selected_list = i + 1
            Exit For
        End If
Next i

End Function


Function Validatie() As Boolean

Validatie = True

Dim iGebruiker As Variant
Dim sh As Worksheet
With frmForm

'std kleur

    .cmbType.BackColor = vbWhite
    .cmbTeam.BackColor = vbWhite
    .txtContactpersoon.BackColor = vbWhite
    .txtTelefoon.BackColor = vbWhite
'----------------------------

' definitie welke moeten ingevuld zijn

If Trim(.cmbType.Value) = "" Then
    MsgBox " Gelieve uit de lijst kiezen!", vbOKOnly + vbInformation, "Welke Type?"
    Validatie = False
    .cmbType.BackColor = vbRed
    .cmbType.SetFocus
    Exit Function
    End If
   
If .OptOut.Value = False And .OptIn.Value = False Then
    MsgBox "Maak een keuze!IN of OUT", vbOKOnly + vbInformation, "StaVaZa"
    Validatie = False
    Exit Function
    End If
    
If Trim(.cmbTeam.Value) = "" Then
    MsgBox " Gelieve uit de lijst kiezen!", vbOKOnly + vbInformation, "Geen Team?"
    Validatie = False
    .cmbTeam.BackColor = vbRed
    .cmbTeam.SetFocus
    Exit Function
    End If
   
If Trim(.txtContactpersoon.Value) = "" Then
    MsgBox " Gelieve een naam in te vullen!", vbOKOnly + vbInformation, "Geen Naam?"
    Validatie = False
    .txtContactpersoon.BackColor = vbRed
    .txtContactpersoon.SetFocus
    Exit Function
    End If
   
If Trim(.txtTelefoon.Value) = "" Then
    MsgBox " Gelieve een telefoonnummer in te vullen!", vbOKOnly + vbInformation, "Geen Telefoon?"
    Validatie = False
    .txtTelefoon.BackColor = vbRed
    .txtTelefoon.SetFocus
    Exit Function
    End If
'----------------------------
End With


End Function
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top