problem getting data from sheet into txt_boxes in userform

  • Thread starter Pierre via OfficeKB.com
  • Start date
P

Pierre via OfficeKB.com

Hi experts,

I have a very urgent problem getting saved data from a sheet into the
txt_boxes in my userform.
I use 2 userforms.
- userform1 called startformulier
- userform2 called open_form
I have a few sheets called:
- staffelberekening
- database

Startformulier is used by the user to input all the data.
On this userform i have the buttons 'save' and 'open'
The save button saves all the data from the userform on a seperate sheet
caled 'database'
On the 'startformulier' form i have a lot of txt_boxes and here's the problem.

if i open a company from the 'database' sheet,
- all the txt_boxes that do not have a controlsource are not filled with
data from the databasesheet.
- all the txt_boxes that do have a controlsource in the 'calc' sheet are
updated !

Here is part of the code i use to open a company:

Private Sub but_ok_klantkeuze_Click()
Dim rng As Range
Dim klantmatrix As Range
Set klantmatrix = Worksheets("database").Range("A2:AZ1500").Find(klantkeuze)
1 If Not klantmatrix Is Nothing Then
2 Sheets("staffelberekening").Range("J3") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column)
3 Sheets("staffelberekening").Range("J5") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 1)
4 Sheets("staffelberekening").Range("J4") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 2)
5 Sheets("staffelberekening").Range("D9") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 3)
6 cbo_bepaling_rr = Worksheets("database").Cells(klantmatrix.Row,
klantmatrix.Column + 4)
7 If cbo_bepaling_rr = "0,03" Then
8 Worksheets("staffelberekening").Range("D8") = "3%"
9 Else: Worksheets("staffelberekening").Range("D8") = "4%"
10 End If
11 Sheets("staffelberekening").Range("J6") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 5)
12 Sheets("staffelberekening").Range("J7") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 6)
13 txt_stijgingsal = Worksheets("database").Cells(klantmatrix.Row,
klantmatrix.Column + 7)
14 Worksheets("staffelberekening").Range("J9").Value = txt_stijgingsal
/ 100
txt_stijgingfran = Worksheets("database").Cells(klantmatrix.Row,
klantmatrix.Column + 8)
Worksheets("staffelberekening").Range("J10").Value =
txt_stijgingfran / 100
Sheets("staffelberekening").Range("D3") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 9)
Sheets("staffelberekening").Range("D4") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 10)
Sheets("staffelberekening").Range("G4") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 11)
Sheets("staffelberekening").Range("D5") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 12)
Sheets("staffelberekening").Range("G5") =
Worksheets("database").Cells(klantmatrix.Row, klantmatrix.Column + 13)
txt_hui_eb_hoofd = Worksheets("database").Cells(klantmatrix.Row,
klantmatrix.Column + 14)
end sub

As you can see, i use two different statements to fill cells or txt_boxes.
The txt_boxes that have a controlsource are automitically updated when i open
a company ande the data is put in the 'staffelberekening' sheet.
however, because some txt_boxes do not have a controlsource, i try to fill
them
directly from the database sheet (see line 13 for example)
If i put in a msgbox line after for example line 13 giving me the
txt_stijgingsal, i get the right value (number) but it does not display on
the form.
Can you help me get all the data in the userform please?
Thanks,
Pierre
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top