Function works erratically

D

Dudley

I have a function in Access 2000 which is called by F6 as follows:

Public Function BonaFideFormation()
Forms![Enquiries]![Type] = "FORMB"
Forms![Enquiries]![Price] = "£77.97"
Forms![Enquiries]![Non VAT] = "£15"
Forms![Enquiries]![VAT] = "£11.03"
Forms![Enquiries]![Price inc VAT] = "£89"
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
DoCmd.GoToControl "Order Date"
End Function

Type and Note are text fields and the rest are currency fields (apart from
Order Date). If I press F6 without entering data into a record the function
works, but if I first enter data in other fields (ie not ones included in the
function) and then press F6, the function works for the text fields but not
for the currency ones. Can anyone tell me why and how I solve the problem?

Thanks
Dudley
 
D

Douglas J. Steele

Presumably your currency fields are Price, Non VAT, VAT and Price inc VAT.

Assuming that they're bound to Currency fields in your table, remove the
quotes and the pound signs:

Public Function BonaFideFormation()

Forms![Enquiries]![Type] = "FORMB"
Forms![Enquiries]![Price] = 77.97
Forms![Enquiries]![Non VAT] = 15
Forms![Enquiries]![VAT] = 11.03
Forms![Enquiries]![Price inc VAT] = 89
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
Forms![Enquiries]![Order Date].SetFocus

End Function

Note, too, that I replaced your GoTo statement with SetFocus.
 
D

Dudley

Thanks for your help. However, I have replaced my function as you advise with
copy and paste and I still have the same problem.

Regards
Dudley

Douglas J. Steele said:
Presumably your currency fields are Price, Non VAT, VAT and Price inc VAT.

Assuming that they're bound to Currency fields in your table, remove the
quotes and the pound signs:

Public Function BonaFideFormation()

Forms![Enquiries]![Type] = "FORMB"
Forms![Enquiries]![Price] = 77.97
Forms![Enquiries]![Non VAT] = 15
Forms![Enquiries]![VAT] = 11.03
Forms![Enquiries]![Price inc VAT] = 89
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
Forms![Enquiries]![Order Date].SetFocus

End Function

Note, too, that I replaced your GoTo statement with SetFocus.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dudley said:
I have a function in Access 2000 which is called by F6 as follows:

Public Function BonaFideFormation()
Forms![Enquiries]![Type] = "FORMB"
Forms![Enquiries]![Price] = "£77.97"
Forms![Enquiries]![Non VAT] = "£15"
Forms![Enquiries]![VAT] = "£11.03"
Forms![Enquiries]![Price inc VAT] = "£89"
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
DoCmd.GoToControl "Order Date"
End Function

Type and Note are text fields and the rest are currency fields (apart from
Order Date). If I press F6 without entering data into a record the
function
works, but if I first enter data in other fields (ie not ones included in
the
function) and then press F6, the function works for the text fields but
not
for the currency ones. Can anyone tell me why and how I solve the problem?

Thanks
Dudley
 
D

Douglas J. Steele

What happens if you open the Immediate Window (Ctrl-G) and type, say,

Forms![Enquiries]![Price] = 77.97

then hit Enter? Does the field in the form get updated?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dudley said:
Thanks for your help. However, I have replaced my function as you advise
with
copy and paste and I still have the same problem.

Regards
Dudley

Douglas J. Steele said:
Presumably your currency fields are Price, Non VAT, VAT and Price inc
VAT.

Assuming that they're bound to Currency fields in your table, remove the
quotes and the pound signs:

Public Function BonaFideFormation()

Forms![Enquiries]![Type] = "FORMB"
Forms![Enquiries]![Price] = 77.97
Forms![Enquiries]![Non VAT] = 15
Forms![Enquiries]![VAT] = 11.03
Forms![Enquiries]![Price inc VAT] = 89
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
Forms![Enquiries]![Order Date].SetFocus

End Function

Note, too, that I replaced your GoTo statement with SetFocus.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dudley said:
I have a function in Access 2000 which is called by F6 as follows:

Public Function BonaFideFormation()
Forms![Enquiries]![Type] = "FORMB"
Forms![Enquiries]![Price] = "£77.97"
Forms![Enquiries]![Non VAT] = "£15"
Forms![Enquiries]![VAT] = "£11.03"
Forms![Enquiries]![Price inc VAT] = "£89"
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
DoCmd.GoToControl "Order Date"
End Function

Type and Note are text fields and the rest are currency fields (apart
from
Order Date). If I press F6 without entering data into a record the
function
works, but if I first enter data in other fields (ie not ones included
in
the
function) and then press F6, the function works for the text fields but
not
for the currency ones. Can anyone tell me why and how I solve the
problem?

Thanks
Dudley
 
D

Dudley

Yes it does, and I have found that the fields are updated if I exit the
record and return to it. I have thus found that this works:

Public Function StandardFormation()
Forms![Enquiries]![Type] = "FORM"
Forms![Enquiries]![Price] = 77.97
Forms![Enquiries]![Non VAT] = 15
Forms![Enquiries]![VAT] = 11.03
Forms![Enquiries]![Price inc VAT] = 89
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
DoCmd.GoToRecord , , acNext
DoCmd.GoToRecord , , acPrevious
DoCmd.GoToControl "Order Date"
End Function

Thanks very much for all your help.

Dudley

Douglas J. Steele said:
What happens if you open the Immediate Window (Ctrl-G) and type, say,

Forms![Enquiries]![Price] = 77.97

then hit Enter? Does the field in the form get updated?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dudley said:
Thanks for your help. However, I have replaced my function as you advise
with
copy and paste and I still have the same problem.

Regards
Dudley

Douglas J. Steele said:
Presumably your currency fields are Price, Non VAT, VAT and Price inc
VAT.

Assuming that they're bound to Currency fields in your table, remove the
quotes and the pound signs:

Public Function BonaFideFormation()

Forms![Enquiries]![Type] = "FORMB"
Forms![Enquiries]![Price] = 77.97
Forms![Enquiries]![Non VAT] = 15
Forms![Enquiries]![VAT] = 11.03
Forms![Enquiries]![Price inc VAT] = 89
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
Forms![Enquiries]![Order Date].SetFocus

End Function

Note, too, that I replaced your GoTo statement with SetFocus.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a function in Access 2000 which is called by F6 as follows:

Public Function BonaFideFormation()
Forms![Enquiries]![Type] = "FORMB"
Forms![Enquiries]![Price] = "£77.97"
Forms![Enquiries]![Non VAT] = "£15"
Forms![Enquiries]![VAT] = "£11.03"
Forms![Enquiries]![Price inc VAT] = "£89"
Forms![Enquiries]![Note] = "VAT not charged on £15 official fee"
DoCmd.GoToControl "Order Date"
End Function

Type and Note are text fields and the rest are currency fields (apart
from
Order Date). If I press F6 without entering data into a record the
function
works, but if I first enter data in other fields (ie not ones included
in
the
function) and then press F6, the function works for the text fields but
not
for the currency ones. Can anyone tell me why and how I solve the
problem?

Thanks
Dudley
 

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