I'd like to creat a function which fills in textboxes...
The function should do something like this...
txtVarType = rs.Fields("Type")
txtVarPrice = rs.Fields("SalesPrice")
txtVarDescr = rs.Fields("Description")
Public Function Filltextbox(Fill As String)
"txt" & Fill & "Type" = rs.Fields("Type")
"txt" & Fill & "Price" = rs.Fields("SalesPrice")
"txt" & Fill & "Descr" = rs.Fields("Description")
End Function
Initiating the function as follows...
Filltextbox(Var)
Filltextbox(Var2)
Filltextbox(Var3)
But this..."txt" & Fill & "Type" doesn't seem to work..Can anyone help?
Public Function Filltextbox(Fill As integer)
txtVarType(Fill) = rs.Fields("Type")
txtVarTypePrice(Fill) = rs.Fields("SalesPrice")
txtVarTypeDescr(Fill) = rs.Fields("Description")
End Function
Initiating the function as follows...
Filltextbox(1)
Filltextbox(2)
Filltextbox(3)
Couple of ways to do this one, i'd use this one normally:
Each conrtol on a form is a menber of the form.controls collection. You can call on this collection to reference your textbox :
VB Code:
Public Function Filltextbox(Fill As String)
me.controls("txt" & Fill & "Type") = rs.Fields("Type")
me.controls(""txt" & Fill & "Price") = rs.Fields("SalesPrice")
me.controls(""txt" & Fill & "Descr") = rs.Fields("Description")
End Function
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details