dmax issue

J

JohnE

I have a form that has on it a cboFileLetter(textfield), txtFileNo
(numberfield) and a button (there are other controls but not relevent for
this posting). When the button is clicked I need to have txtFileNo fill in
with the next incremental number for the letter that has been selected in
cboFileLetter. The code in the click event that I have so far is;

Me.txtFileNo.Value = Nz(DMax("[FileNo]", "[tbl_Clients]", "FileLetter=" &
Me.cboFileLetter), 0) + 1

This is not working and I get an error 2001 - you canceled the previous
action.

I seek help on this dillemma.

Thanks in advance for the help.
*** John
 
C

Carl Rapson

JohnE said:
I have a form that has on it a cboFileLetter(textfield), txtFileNo
(numberfield) and a button (there are other controls but not relevent for
this posting). When the button is clicked I need to have txtFileNo fill
in
with the next incremental number for the letter that has been selected in
cboFileLetter. The code in the click event that I have so far is;

Me.txtFileNo.Value = Nz(DMax("[FileNo]", "[tbl_Clients]", "FileLetter=" &
Me.cboFileLetter), 0) + 1

This is not working and I get an error 2001 - you canceled the previous
action.

I seek help on this dillemma.

Thanks in advance for the help.
*** John

What is the datatype of the FileLetter field in tbl_Clients? If it's text,
you'll need to put quotes around the value you're testing:

Me.txtFileNo.Value = Nz(DMax("[FileNo]", "[tbl_Clients]", "FileLetter='"
& Me.cboFileLetter & "'"), 0) + 1

Carl Rapson
 
J

JohnE

Carl, thanks for the reply. It is text and I just realized my error.
Thanks.


Carl Rapson said:
JohnE said:
I have a form that has on it a cboFileLetter(textfield), txtFileNo
(numberfield) and a button (there are other controls but not relevent for
this posting). When the button is clicked I need to have txtFileNo fill
in
with the next incremental number for the letter that has been selected in
cboFileLetter. The code in the click event that I have so far is;

Me.txtFileNo.Value = Nz(DMax("[FileNo]", "[tbl_Clients]", "FileLetter=" &
Me.cboFileLetter), 0) + 1

This is not working and I get an error 2001 - you canceled the previous
action.

I seek help on this dillemma.

Thanks in advance for the help.
*** John

What is the datatype of the FileLetter field in tbl_Clients? If it's text,
you'll need to put quotes around the value you're testing:

Me.txtFileNo.Value = Nz(DMax("[FileNo]", "[tbl_Clients]", "FileLetter='"
& Me.cboFileLetter & "'"), 0) + 1

Carl Rapson
 

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


Top