displaying field values

M

Mark Kubicki

[this code, out of context, will seem irrational alluding to poorly design
data base... don't be concerned, as used, it's not so absurd]

I have 2 tables with identical fields,
tbl... has multiple records
tbe... has only one record
cboPresetOption is a combo box on the current form

I am trying to simply display a list that compares the equivalent values in
the 2 tables
later, I will assign the values of the selected record in the tbl table to
the single record in the tbe table

the result I get is:
the field name (correct), its value in the tbl table (correct), and text:
which reads something like this: rstTBE.field.name.value (incorrect - it
should be the actual value of the field)

Any thoughts would be appreciated
thanks inadvance,
mark

---------------------------------------------------------------
Private Sub cboPresetOption_Change()
Set Db = CurrentDb()
Dim rstTBL As DAO.Recordset
Dim rstTBE As DAO.Recordset
Dim fld As DAO.Field

Set rstTBL = Db.OpenRecordset("SELECT * FROM
[tblFixtureSchedulePrintOptions] where [PresetOption] = " &
Me.cboPresetOption)
Set rstTBE = Db.OpenRecordset("SELECT * FROM
[tbeFixtureSchedulePrintOptions]")

VStr = ""
With rstTBL
For Each fld In .Fields
TBLvalue = fld.Value
TBEvalue = "rstTBE." & fld.Name & ".Value"
VStr = VStr & fld.Name & " - " & TBLvalue & " ~ " & TBEValue &
Chr(10) & Chr(13)
Next fld
End With

msgbox Vstr
 
M

Marshall Barton

Mark said:
[this code, out of context, will seem irrational alluding to poorly design
data base... don't be concerned, as used, it's not so absurd]

I have 2 tables with identical fields,
tbl... has multiple records
tbe... has only one record
cboPresetOption is a combo box on the current form

I am trying to simply display a list that compares the equivalent values in
the 2 tables
later, I will assign the values of the selected record in the tbl table to
the single record in the tbe table

the result I get is:
the field name (correct), its value in the tbl table (correct), and text:
which reads something like this: rstTBE.field.name.value (incorrect - it
should be the actual value of the field)

Any thoughts would be appreciated
thanks inadvance,
mark

---------------------------------------------------------------
Private Sub cboPresetOption_Change()
Set Db = CurrentDb()
Dim rstTBL As DAO.Recordset
Dim rstTBE As DAO.Recordset
Dim fld As DAO.Field

Set rstTBL = Db.OpenRecordset("SELECT * FROM
[tblFixtureSchedulePrintOptions] where [PresetOption] = " &
Me.cboPresetOption)
Set rstTBE = Db.OpenRecordset("SELECT * FROM
[tbeFixtureSchedulePrintOptions]")

VStr = ""
With rstTBL
For Each fld In .Fields
TBLvalue = fld.Value
TBEvalue = "rstTBE." & fld.Name & ".Value"


I think you want to use:
TBEvalue = rstTBE(fld.Name)
Or
TBEvalue = rstTBE(fld.Name).Value
Or
TBEvalue = rstTBE.Fields(fld.Name)
Or
TBEvalue = rstTBE.Fields(fld.Name).Value
 
M

Mark Kubicki

perfect.. thanks
-m.



Marshall Barton said:
Mark said:
[this code, out of context, will seem irrational alluding to poorly design
data base... don't be concerned, as used, it's not so absurd]

I have 2 tables with identical fields,
tbl... has multiple records
tbe... has only one record
cboPresetOption is a combo box on the current form

I am trying to simply display a list that compares the equivalent values
in
the 2 tables
later, I will assign the values of the selected record in the tbl table to
the single record in the tbe table

the result I get is:
the field name (correct), its value in the tbl table (correct), and text:
which reads something like this: rstTBE.field.name.value (incorrect - it
should be the actual value of the field)

Any thoughts would be appreciated
thanks inadvance,
mark

---------------------------------------------------------------
Private Sub cboPresetOption_Change()
Set Db = CurrentDb()
Dim rstTBL As DAO.Recordset
Dim rstTBE As DAO.Recordset
Dim fld As DAO.Field

Set rstTBL = Db.OpenRecordset("SELECT * FROM
[tblFixtureSchedulePrintOptions] where [PresetOption] = " &
Me.cboPresetOption)
Set rstTBE = Db.OpenRecordset("SELECT * FROM
[tbeFixtureSchedulePrintOptions]")

VStr = ""
With rstTBL
For Each fld In .Fields
TBLvalue = fld.Value
TBEvalue = "rstTBE." & fld.Name & ".Value"


I think you want to use:
TBEvalue = rstTBE(fld.Name)
Or
TBEvalue = rstTBE(fld.Name).Value
Or
TBEvalue = rstTBE.Fields(fld.Name)
Or
TBEvalue = rstTBE.Fields(fld.Name).Value
 

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