concatenate textbox name

checoturco

Registered User.
Local time
Yesterday, 16:25
Joined
Oct 17, 2005
Messages
76
hi guys, this is my first post because i start probramminh with vba just a few days ago a need some help.


i need to concatenate a textbox name, i.e

i have 10 textbox´s with names ns_1,ns_2,ns_...
the 1 value must be catch from a variable and i need to concatenate that variable with the name of text box.

something like this:
ns_"& i &".value=rs...

tks in advance

checo
 
Just a guess but it should look something like this...

ns_1 & ns_2 & ns_3

or

ns_1 & ", " & ns_2 & ", " & ns_3
 
ns_1, ns_2, ns_3,...

Looks like normalization issues... :)
 
well. i think that i don´t explain my self very well.

i have a do until cicle and the variable i is incremented at every cicle step, so, while not end of the cicle, the text box's name is changed with the i variable.
here is my code:

Set rst = db.OpenRecordset("select * from experience where idexp=" & aud.Value & ";")
rst.MoveFirst
Do Until rst.EOF
i = i + 1
If Not IsNull(rst("n_exper")) Then
Forms!insert_data!ns_& i & .Value = rst("n_exper")
ns_& i &.Visible = True
End If
rst.MoveNext
Loop
 
Last edited:
try it like:-
Forms!insert_data("ns_" & i).Value = rst("n_exper")

HTH

Peter
 
hi guys,

i have the same problem of wanting to concatenate a textbox name, however i need to do it for a CreateObject method as my text boxes are being created dynamically..I have the following code:


RecCount = 0
If Not rs.EOF Then rs.MoveFirst
Do While Not rs.EOF

Set Forms!Create_Despatch("BookingType" & RecCount) = CreateControl("Create_Despatch", acTextBox, acDetail, , , 270, 1400, 650, 270)

RecCount = RecCount + 1
rs.MoveNext
Loop


I'm getting this error: "Microsoft Access can't find the field BookingType0 referred to in your expression".

This means that Access is recognising the experession and concatenating the name with RecCount, however, seems like it's expecting a declaration? I tried doing a Dim statement : Dim Forms!Create_Despatch("BookingType" & RecCount) As New Control, but I get an error 'identifier expected' at the beginning of the expression.

Any suggestions greatly appreciated..tnx:)
 
hi ray147

in my case, the text box ns_1,ns_2,... exists.

you have a text box called BookingType0 ?
 

Users who are viewing this thread

Back
Top Bottom