refering to a field on a form

J

JethroUK©

i'm trying to count records:


MsgBox DCount("[ID]", "QUALS", "ID = " & Me!quals!ID)


but i'm not sure how to reference a field content on the current record of
the form
the field is included in the form record source (query incl two tables) but
not in a textbox - tried:

Me!quals!ID
Me![quals]![ID]

or an alternative way of counting?
 
A

Allen Browne

If the field is named ID, use:
MsgBox DCount("[ID]", "QUALS", "ID = " & Me!ID)
 
G

Guest

Jethro,

Your problem doubtlessly lies in the expression Me!quals!ID. Assuming you
are running the code within the form then Me refers to that form. So what
does quals!ID mean? You have two terms where I would expect only one, that
of the name of the control on your form that contains the value. If the name
of the control is ID then Me!ID will suffice.

Regards,

Rod
 
J

JethroUK©

i think what complicates it further is that the form is based on a query,
which is in turn based on two tables - both of which have an ID field
(tie) - so i have to identify the table too e.g.

Me!quals!ID

this doesn't seem to work (can't find the field) - but is it the right
syntax?



Allen Browne said:
If the field is named ID, use:
MsgBox DCount("[ID]", "QUALS", "ID = " & Me!ID)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JethroUK) said:
i'm trying to count records:


MsgBox DCount("[ID]", "QUALS", "ID = " & Me!quals!ID)


but i'm not sure how to reference a field content on the current record of
the form
the field is included in the form record source (query incl two tables)
but
not in a textbox - tried:

Me!quals!ID
Me![quals]![ID]

or an alternative way of counting?
 
J

JethroUK©

found it

Me![QUALS.ID]

thanks for the help


JethroUK© said:
i think what complicates it further is that the form is based on a query,
which is in turn based on two tables - both of which have an ID field
(tie) - so i have to identify the table too e.g.

Me!quals!ID

this doesn't seem to work (can't find the field) - but is it the right
syntax?



Allen Browne said:
If the field is named ID, use:
MsgBox DCount("[ID]", "QUALS", "ID = " & Me!ID)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JethroUK) said:
i'm trying to count records:


MsgBox DCount("[ID]", "QUALS", "ID = " & Me!quals!ID)


but i'm not sure how to reference a field content on the current
record
of
the form
the field is included in the form record source (query incl two tables)
but
not in a textbox - tried:

Me!quals!ID
Me![quals]![ID]

or an alternative way of counting?
 
A

Allen Browne

It might be possible to use something like this:
Me.Recordset.Fields("quals!ID")

But a better alternative would be to alias the field in the query that feeds
your form. Instead of just ID in the Field row of the query, use another
name, such as:
TheQualsID: ID

Now you have a unique name for it, so you can then use:
Me!TheQualsID

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JethroUK) said:
i think what complicates it further is that the form is based on a query,
which is in turn based on two tables - both of which have an ID field
(tie) - so i have to identify the table too e.g.

Me!quals!ID

this doesn't seem to work (can't find the field) - but is it the right
syntax?



Allen Browne said:
If the field is named ID, use:
MsgBox DCount("[ID]", "QUALS", "ID = " & Me!ID)

JethroUK) said:
i'm trying to count records:


MsgBox DCount("[ID]", "QUALS", "ID = " & Me!quals!ID)


but i'm not sure how to reference a field content on the current record of
the form
the field is included in the form record source (query incl two tables)
but
not in a textbox - tried:

Me!quals!ID
Me![quals]![ID]

or an alternative way of counting?
 

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