0
votes

I was searching for my question for hours and I have found some ideas but it still doesn't do what I want.

I have a form "AddWorker" with texboxes "Name", "Surname" and so on. At the end of this form I decided to use a button to handle addition to database by VBA code.

When I put some data into texboxes I can refer to them by textbox.text property, but only if I am focused on this texbox. In other cases I can use textbox.value property.

In my case when I put all data into 3 textboxes I clik button "Add worker" to add person to database, but last textbox (for example 3) is seen as empty because it did't see text I have put into textbox. I need to clik into another textbox (for example 2 or 1) to create "some event" and then it update textbox 3 and all data can be read in vBA.

What can I do to see all texboxes filled in VBA when i click "Add worker" button.

I have found some example but it didn't help me a lot. I still see empty textbox while clicking "Add worker" button. Textbox null problem

1

1 Answers

0
votes

First of all, make sure the form is unbound. It should not have a recordsource associated with it.

Then, try adding a few messageboxes in the code behind the Add Worker button. Something like:

Sub Add_Worker_Click()

    msgbox "Text1: " & Me.TextBox1.Value
    msgbox "Text2: " & Me.TextBox2.Value
    msgbox "Text3: " & Me.TextBox3.Value

    /* Comment out all of your code for now */

End Sub

Give that a shot and see what is in the textboxes. Then replace ".Value" with ".Text" and see what you get.