By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,204 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,204 IT Pros & Developers. It's quick & easy.

Try to set values of a text box thru code

P: n/a
I try to to set the value of a text box through code and it will always
display the same value in every record. I think i cant display a
recordset in a text box. What way i use so that i can display my values
in the text box.

Private Sub Form_Open(Cancel As Integer)
Dim qry As String, rst As Object
qry = "SELECT tbl_EquipmentChronology.Equipment1 FROM
tbl_EquipmentChronology INNER JOIN tbl_events ON
tbl_events.TicketNum=tbl_EquipmentChronology.Ticke tNum where
tbl_events.TicketNum=" &
Forms!tbl_PPVResearch_Edit!frm_Events!TicketNum & " and
tbl_events.PPVVOD_Outlet=tbl_EquipmentChronology.O utlet"
Set rst = CurrentDb.OpenRecordset(qry)
rst.MoveFirst
Do While Not rst.EOF
Forms!tbl_PPVResearch_Edit!frm_Events![Text2] = rst!Equipment1
rst.MoveNext
Loop
End Sub

Aug 15 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Eric,

Why are you looping through the file with the 'Do While Not rst.EOF'
line of code.

Nick

Eric wrote:
I try to to set the value of a text box through code and it will always
display the same value in every record. I think i cant display a
recordset in a text box. What way i use so that i can display my values
in the text box.

Private Sub Form_Open(Cancel As Integer)
Dim qry As String, rst As Object
qry = "SELECT tbl_EquipmentChronology.Equipment1 FROM
tbl_EquipmentChronology INNER JOIN tbl_events ON
tbl_events.TicketNum=tbl_EquipmentChronology.Ticke tNum where
tbl_events.TicketNum=" &
Forms!tbl_PPVResearch_Edit!frm_Events!TicketNum & " and
tbl_events.PPVVOD_Outlet=tbl_EquipmentChronology.O utlet"
Set rst = CurrentDb.OpenRecordset(qry)
rst.MoveFirst
Do While Not rst.EOF
Forms!tbl_PPVResearch_Edit!frm_Events![Text2] = rst!Equipment1
rst.MoveNext
Loop
End Sub
Aug 15 '06 #2

P: n/a
Because there are more then one value in the table. Is this is wrong?
Nick 'The database Guy' wrote:
Hi Eric,

Why are you looping through the file with the 'Do While Not rst.EOF'
line of code.

Nick

Eric wrote:
I try to to set the value of a text box through code and it will always
display the same value in every record. I think i cant display a
recordset in a text box. What way i use so that i can display my values
in the text box.

Private Sub Form_Open(Cancel As Integer)
Dim qry As String, rst As Object
qry = "SELECT tbl_EquipmentChronology.Equipment1 FROM
tbl_EquipmentChronology INNER JOIN tbl_events ON
tbl_events.TicketNum=tbl_EquipmentChronology.Ticke tNum where
tbl_events.TicketNum=" &
Forms!tbl_PPVResearch_Edit!frm_Events!TicketNum & " and
tbl_events.PPVVOD_Outlet=tbl_EquipmentChronology.O utlet"
Set rst = CurrentDb.OpenRecordset(qry)
rst.MoveFirst
Do While Not rst.EOF
Forms!tbl_PPVResearch_Edit!frm_Events![Text2] = rst!Equipment1
rst.MoveNext
Loop
End Sub
Aug 15 '06 #3

P: n/a
This unbound textbox in a continuous form really give me a hard time
since two days. Now i try it in another way. I create a query in a
query designer name query5 and in the control source of textbox name
text2(unBound) wrote the following

=[Query5]![Equipment1]:

Query5
SELECT tbl_EquipmentChronology.Equipment1, tbl_Events.PPVVOD_Outlet,
tbl_EquipmentChronology.Outlet, tbl_Events.TicketNum
FROM tbl_Events INNER JOIN tbl_EquipmentChronology ON
(tbl_Events.TicketNum = tbl_EquipmentChronology.TicketNum) AND
(tbl_Events.PPVVOD_Outlet = tbl_EquipmentChronology.Outlet) WHERE
(((tbl_Events.TicketNum)=" &
Forms!tbl_PPVResearch_Edit!frm_Events!TicketNum & and
tbl_events.PPVVOD_Outlet=tbl_EquipmentChronology.O utlet"));

But this time it print these values in the form

#Name?
#Name?
#Name?

I need only the display in text2 box thats why i didnt bind with the
table.

Thanks in advance.
--------------------------------------------------------------------------------------------------
Eric wrote:
Because there are more then one value in the table. Is this is wrong?
Nick 'The database Guy' wrote:
Hi Eric,

Why are you looping through the file with the 'Do While Not rst.EOF'
line of code.

Nick

Eric wrote:
I try to to set the value of a text box through code and it will always
display the same value in every record. I think i cant display a
recordset in a text box. What way i use so that i can display my values
in the text box.
>
Private Sub Form_Open(Cancel As Integer)
Dim qry As String, rst As Object
qry = "SELECT tbl_EquipmentChronology.Equipment1 FROM
tbl_EquipmentChronology INNER JOIN tbl_events ON
tbl_events.TicketNum=tbl_EquipmentChronology.Ticke tNum where
tbl_events.TicketNum=" &
Forms!tbl_PPVResearch_Edit!frm_Events!TicketNum & " and
tbl_events.PPVVOD_Outlet=tbl_EquipmentChronology.O utlet"
Set rst = CurrentDb.OpenRecordset(qry)
rst.MoveFirst
Do While Not rst.EOF
Forms!tbl_PPVResearch_Edit!frm_Events![Text2] = rst!Equipment1
rst.MoveNext
Loop
End Sub
Aug 15 '06 #4

P: n/a
Wow. You like to make things very hard.

Why not just create a query that calculates whatever you want, and then
base the subform on that? As long as you include the foreign key, it
should be updateable.

Aug 15 '06 #5

P: n/a
Can you please send me a query with foreign key include as a sample. I
want to compare with my query. Right now the query which i created it
shows that result in the form and in the control source of textbox i
call my query.
#Name?
#Name?
#Name?
This is my query:
SELECT tbl_EquipmentChronology.Equipment1, tbl_Events.PPVVOD_Outlet,
tbl_EquipmentChronology.Outlet, tbl_Events.TicketNum
FROM tbl_Events INNER JOIN tbl_EquipmentChronology ON
(tbl_Events.TicketNum = tbl_EquipmentChronology.TicketNum) AND
(tbl_Events.PPVVOD_Outlet = tbl_EquipmentChronology.Outlet)
WHERE (((tbl_Events.TicketNum)=" &
Forms!tbl_PPVResearch_Edit!frm_Events!TicketNum & and
tbl_events.PPVVOD_Outlet=tbl_EquipmentChronology.O utlet"));

pi********@hotmail.com wrote:
Wow. You like to make things very hard.

Why not just create a query that calculates whatever you want, and then
base the subform on that? As long as you include the foreign key, it
should be updateable.
Aug 16 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.