Refering to Values

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I have a bound form. I need to refer to field values to do certain
actions but I don't want to have these fields on the form for speed
reasons. Nothing will be put into these fields as they are filled
earlier. How can I do this?
Thanks
DS
 
DS said:
I have a bound form. I need to refer to field values to do certain
actions but I don't want to have these fields on the form for speed
reasons. Nothing will be put into these fields as they are filled
earlier. How can I do this?
Thanks
DS

Controls on a bound form (there are no fields on a form) merely hold the
data from the underlying fields in the form's recordsource. You can refer to
the field in the same way you refer to the controls, which is why it's good
to name the controls differently.

Forms!MyForm!MyField

can refer to either a field or a control if they both have the same name.

Forms!MyForm!txtMyField
Me.txtMyField

and several similar syntax usages refer to a textbox on a form names
txtMyField
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Arvin said:
Controls on a bound form (there are no fields on a form) merely hold the
data from the underlying fields in the form's recordsource. You can refer to
the field in the same way you refer to the controls, which is why it's good
to name the controls differently.

Forms!MyForm!MyField

can refer to either a field or a control if they both have the same name.

Forms!MyForm!txtMyField
Me.txtMyField

and several similar syntax usages refer to a textbox on a form names
txtMyField
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
So this is starting to look like good news! So if I have to refer to
lets say field CheckType...and I don't have it on the form but it's in
the table....this is what i do?
If CheckType = 1 Then
DoCmd.OpenForm..etc
Else:
End If

or do I have to refer to the table that its in?
If Sales.CheckType = 1 Then
DoCmd.......
Else
End If

Thanks
DS
 
DS said:
So this is starting to look like good news! So if I have to refer to lets
say field CheckType...and I don't have it on the form but it's in the
table....this is what i do?
If CheckType = 1 Then
DoCmd.OpenForm..etc
Else:
End If

or do I have to refer to the table that its in?
If Sales.CheckType = 1 Then
DoCmd.......
Else
End If

As Arvin said, you need to use either Forms!MyForm!CheckType (where you'd
replace MyForm with the actual name of your form), or the shorthand
Me!CheckType
 
Back
Top