View Single Post
  #2  
Old May 10th, 2010, 03:28 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Quote Form With Options - Repost

I don't know what exactly was in the original string, but I see a few things
in the code you posted.

I'm not sure what this line of code is supposed to do:

Me.JobNumber.DefaultValue = """" & Me.JobNumber.Value & """"

For clarity in posting and in reading the code, I suggest naming the text box
differently from the field to which it is bound. For instance, the text box
could be txtJobNumber.

However, that is probably unrelated to the problem with this line. It seems
the Default Value of JobNumber is the value of Job Number, which is circular.
Also, the quotes are not necessary, and may be doing some harm. From your
posting, you are trying to carry JobNumber from the previous record to the
new record. Why is that? Is this code in a subform? If so, and if
JobNumber is the linking field between the main form and subform tables, it
needs to be the Link Child and Link Master properties of the subform control
(the "box" containing the subform).

One problem with the next line may be that Option is a reserved word. For
more about reserved words:
http://www.allenbrowne.com/Ap****ueBadWord.html

Option should not be used as a name, but if it is used it should be in square
brackets, and it probably should be the DefaultValue, or else it will change
whenever the code is run. You can't rely on users not clicking a "dangerous"
button:
Me.txtOption.DefaultValue = Nz(DMax("[Option]", "tquotemainform"), 0) + 1

Is tquotemainform a table?

PHisaw wrote:
It seems my original thread of 4/29/10 "Quote Form with Options" has been
forgotten. Tom van Stiphout was helping and gave me the instructions for a
button to ""Create New
Option". It would look at the maximum option used so far (DMax
function) and add 1 to it.
When the button is clicked, you save the JobNumber information and
perhaps some other key information, go to a new record, populate the
JobNumber with the saved value, and set the Option field to whatever
DMax(...)+1 returns."

I have researched and tried several methods of code, but can't seem to get
anything to work other than the option field increasing in number. This is
currently what I have which throws an error message "can't go to specified
record" and highlights the GoToRecord,,acNewRec line. I think it has
something to do with the job number, but can't figure out how to correct it.

Private Sub LblQuoteOptions_Click()

DoCmd.RunCommand acCmdSave
DoCmd.GoToRecord , , acNewRec
Me.JobNumber.DefaultValue = """" & Me.JobNumber.Value & """"
Me.Option = Nz(DMax("Option", "tquotemainform"), 0) + 1

End Sub

Any suggestions would be greatly appreciated.
Thank in advance,
Pam


--
Message posted via http://www.accessmonster.com