userform problem

  • 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
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
 
B

Bob Phillips

Guessing here as we cannot see what the data is or all the rest, but here is
a first shot

txt_stijgingsal.Text =
Worksheets("database").Cells(klantmatrix.Row,klantmatrix.Column + 7).Text
 
P

Pierre via OfficeKB.com

Hi Bob,

Thank you very much for helping me..but sofar no good....

I get the error message : Object expected if I put ".Text" behind the
"txt_stijgingsal" or
"Worksheets("database").Cells(klantmatrix.Row,klantmatrix.Column + 7)" part.

Any other ideas?
Thanks,
Pierre

Bob said:
Guessing here as we cannot see what the data is or all the rest, but here is
a first shot

txt_stijgingsal.Text =
Worksheets("database").Cells(klantmatrix.Row,klantmatrix.Column + 7).Text
Hi experts,
[quoted text clipped - 62 lines]
Thanks,
Pierre
 
P

Pierre via OfficeKB.com

Hi Bob,

some moere info for you and my thoughts....

The code I have to adapt is in userform1.
The txt_stijgingsal textbox is on userform2

Can i be that because the textbox is on userform2, the code underneath
userform1 does not recognise what txt_stijgingsal is ?

If this is the case, how can i solve this problem?
Thanks,
Pierre

Bob said:
Guessing here as we cannot see what the data is or all the rest, but here is
a first shot

txt_stijgingsal.Text =
Worksheets("database").Cells(klantmatrix.Row,klantmatrix.Column + 7).Text
Hi experts,
[quoted text clipped - 62 lines]
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