pwdells
asked on
Working with objects from recordsets.
Hello Everyone,
rs_DynObj.Fields(1) is the Top value I want to set my object to.
So in the database I could have:
Object Top Value (in TWIPs)
TextBox A 1440
Lable A 1440
TxtBox B 2880
Label B 2880
The above recordset could be what my SQL returns.
I have a loop going through each one of the records (objects) returned. I want to dynamically reset the object's top value listed in the adjacent column.
What is the syntax for doing something like
value of rs_dynobj.fields(0) . top = rs_dynobj.fields(1)
Thanks in advance for your assistance.
Best Regards,
Wendee
My Code:
str_DynObj = _
"SELECT tbx_DynamicObjects.Object, tbx_DynamicObjects.Pos1_TopTwips, " & _
"tbx_DynamicObjects.Pos2_TopTwips, tbx_DynamicObjects.FormID, " & _
"tbx_DynamicObjects.TabID, tbx_DynamicObjects.Active " & _
"FROM tbx_DynamicObjects " & _
"WHERE tbx_DynamicObjects.FormID = 22 " & _
"AND tbx_DynamicObjects.TabID = 2 " & _
"AND tbx_DynamicObjects.Active = TRUE "
Set rs_DynObj = db.OpenRecordset(str_DynObj)
While Not rs_DynObj.EOF
MsgBox rs_DynObj.Fields(0) & " | " & rs_DynObj.Fields(1) & " | " & rs_DynObj.Fields(2)
rs_DynObj.MoveNext
Wend
What I Want to do:
rs_DynObj.Fields(0) is the name of my object. Could be a text box or a lable or even a combo box.rs_DynObj.Fields(1) is the Top value I want to set my object to.
So in the database I could have:
Object Top Value (in TWIPs)
TextBox A 1440
Lable A 1440
TxtBox B 2880
Label B 2880
The above recordset could be what my SQL returns.
I have a loop going through each one of the records (objects) returned. I want to dynamically reset the object's top value listed in the adjacent column.
What is the syntax for doing something like
value of rs_dynobj.fields(0) . top = rs_dynobj.fields(1)
Thanks in advance for your assistance.
Best Regards,
Wendee
str_DynObj = _
"SELECT tbx_DynamicObjects.Object, tbx_DynamicObjects.Pos1_TopTwips, " & _
"tbx_DynamicObjects.Pos2_TopTwips, tbx_DynamicObjects.FormID, " & _
"tbx_DynamicObjects.TabID, tbx_DynamicObjects.Active " & _
"FROM tbx_DynamicObjects " & _
"WHERE tbx_DynamicObjects.FormID = 22 " & _
"AND tbx_DynamicObjects.TabID = 2 " & _
"AND tbx_DynamicObjects.Active = TRUE "
Set rs_DynObj = db.OpenRecordset(str_DynObj)
MsgBox rs_DynObj.RecordCount
Dim i As Integer
While Not rs_DynObj.EOF
MsgBox rs_DynObj.Fields(0) & " | " & rs_DynObj.Fields(1) & " | " & rs_DynObj.Fields(2)
rs_DynObj.MoveNext
Wend
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you! Your top suggestion worked!
see this link
CreateControl Method
http://msdn.microsoft.com/en-us/library/aa221167%28office.11%29.aspx