DCount

R

Rob W

Greetings,

It must be late at night as I cant seem to do the most simplest of
activities, a form is used to enter new records.

It displays details and at the bottom is summary information, a text box has
a control source of the following :-

=DCount("[StudentID]", "tblStudent","[AwardId]= '" & [txt.AwardId] &"')

Firstly I keep getting syntax errors and the expression builder upon editing
what i have copied and pasted into the control source property likes
to add quotes and removes the %.

What should the correct syntax be?
Secondly when I navigate or add records how can I get it to be a dynamic
value.

I originally had vba code to set teh txt.Award = DCount("[StudentID]",
"tblStudent","[AwardId]='" & [txt.AwardId] &"') on the form load.
This means though I would have to add the code to my navition buttons (next,
previous, first and last).

Im sure there is an easier way though.

Can anyone please assist?
Apologies for the number of questions tonight!!!

Thanks
Rob
 
J

Jeff Boyce

Rob

Is the [AwardID] a text/string value? The DCount() expression tells Access
to look for a string value.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
R

Rob W

Jeff,

Just doubled checked the database schema and AwardId is a text field.

Cheers
Rob

Jeff Boyce said:
Rob

Is the [AwardID] a text/string value? The DCount() expression tells
Access to look for a string value.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Rob W said:
Greetings,

It must be late at night as I cant seem to do the most simplest of
activities, a form is used to enter new records.

It displays details and at the bottom is summary information, a text box
has a control source of the following :-

=DCount("[StudentID]", "tblStudent","[AwardId]= '" & [txt.AwardId] &"')

Firstly I keep getting syntax errors and the expression builder upon
editing what i have copied and pasted into the control source property
likes
to add quotes and removes the %.

What should the correct syntax be?
Secondly when I navigate or add records how can I get it to be a dynamic
value.

I originally had vba code to set teh txt.Award = DCount("[StudentID]",
"tblStudent","[AwardId]='" & [txt.AwardId] &"') on the form load.
This means though I would have to add the code to my navition buttons
(next, previous, first and last).

Im sure there is an easier way though.

Can anyone please assist?
Apologies for the number of questions tonight!!!

Thanks
Rob
 
R

Rob W

Do I specify values on the form using & [txtAwardId] & ?

Thanks
Rob
Jeff Boyce said:
Rob

Is the [AwardID] a text/string value? The DCount() expression tells
Access to look for a string value.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Rob W said:
Greetings,

It must be late at night as I cant seem to do the most simplest of
activities, a form is used to enter new records.

It displays details and at the bottom is summary information, a text box
has a control source of the following :-

=DCount("[StudentID]", "tblStudent","[AwardId]= '" & [txt.AwardId] &"')

Firstly I keep getting syntax errors and the expression builder upon
editing what i have copied and pasted into the control source property
likes
to add quotes and removes the %.

What should the correct syntax be?
Secondly when I navigate or add records how can I get it to be a dynamic
value.

I originally had vba code to set teh txt.Award = DCount("[StudentID]",
"tblStudent","[AwardId]='" & [txt.AwardId] &"') on the form load.
This means though I would have to add the code to my navition buttons
(next, previous, first and last).

Im sure there is an easier way though.

Can anyone please assist?
Apologies for the number of questions tonight!!!

Thanks
Rob
 
R

Rob W

SOLVED: As I was adding the code straight into the control source did not
have to treat is a variable and use '&' to add it as part of the string.

Rob W said:
Jeff,

Just doubled checked the database schema and AwardId is a text field.

Cheers
Rob

Jeff Boyce said:
Rob

Is the [AwardID] a text/string value? The DCount() expression tells
Access to look for a string value.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Rob W said:
Greetings,

It must be late at night as I cant seem to do the most simplest of
activities, a form is used to enter new records.

It displays details and at the bottom is summary information, a text box
has a control source of the following :-

=DCount("[StudentID]", "tblStudent","[AwardId]= '" & [txt.AwardId] &"')

Firstly I keep getting syntax errors and the expression builder upon
editing what i have copied and pasted into the control source property
likes
to add quotes and removes the %.

What should the correct syntax be?
Secondly when I navigate or add records how can I get it to be a dynamic
value.

I originally had vba code to set teh txt.Award = DCount("[StudentID]",
"tblStudent","[AwardId]='" & [txt.AwardId] &"') on the form load.
This means though I would have to add the code to my navition buttons
(next, previous, first and last).

Im sure there is an easier way though.

Can anyone please assist?
Apologies for the number of questions tonight!!!

Thanks
Rob
 

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

Similar Threads

Checking if txtbox is null and DCount parameter 3
Update query using counts. 2
dcount 1
Dcount question 6
DCount to check duplicates 8
DCount criteria multiple variables 2
HLP! Form Design 5
DCount help 1

Top