Oh Marshall...Have I learned a lot from you...including how to ask a
question. I will, from now on, never forget the importance of the
formatting of a field(s) when asking a question because, yes, with
that change to the code it now works!!!!!!!!
Hooray ;-)
And I should have caught
the word FORMAT and grasped what I was looking at.
Be careful with that word. The Format property has very
little or nothing to do with its value. The really
important thing is the DataType (and for the Number type,
the FieldSize).
I used the Format function on the date field to make sure
that Access would be able to interpret the resulting literal
value independently of the Windows Regional date settings
for the order of the year month and day and the separator
between them. If one of your users decided to set his
machine for the date format (d.m.y) as most of the rest of
the world does then, without the format function, you would
get an error about a number with two decimal points. Even
the standard US style dates m/d/y date would be treated as
two divisions so Access requires the date to be enclosed in
# signs. Putting all that confusion together results in the
formatting I used. The reason we have to go through all
that is because we are concatenating the values in a string
and we don't want Access to guess at the date format.
Numbers are unambiguous so they do not require anything
special. OTOH, a text value concatenated into our SQL
statement would be strange syntax unless it is enclosed in
quotes.
You can see the result of all that conversion and
concatenation by placing a break point on the Execute line
and inspecting the strSQL variable. Eventually you will
learn enough about queries and SQL statements to spot errors
caused by missing delimiters, missing spaces and .
I am still testing
and trying to think up ways to "break" it but so far so good!!
Is it the double quotes that describe cboDept as text rather than a
number?
No. The value of the combo box is determined by the data
type of the bound column field in its row source. The
quotes are required because a literal text value is not
recognizable unless it is in quotes.
Also, for the purposes of my db I have only included 2 depts
at this point which is why I used text instead of a number field as an
index. I am guessing that over time I would probably be better off
creating a numeic index such as DeptID (number), and DeptName
(text)...good and proper thinking?
If a DeptName might be changed in the future, then I think
that's a good idea. OTOH, a static name is sufficient and
an extra number id field would just be an unnecessary extra
mechanism that Murphy might want to utilized in his never
ending quest for ways to cause. The debate over this issue
is a near religious argument. Personally, I usually use the
id number field because I don't trust much of anything to be
static.
At this point - if you have time (and I am grateful for the inordinate
amount of time you have already spent with me) - I would love to hear
your take on my db design. On the other hand - if you don't have time
- I absolutely understand.
I think I have already mentioned the table design points
that I had any questions about.
The concept of using an unbound main form for users to
specify the filter values and using the link master/child
properties to apply the filter to a bound subform is one I
had not really considered before. (Normally a subform is
used when you want to relate records from two tables.)
However, I suspect that it may very well be easier and more
reliable than using the Filter property on a single form, so
I am going to log that away as a potentially good idea.
Right now, now that I am beginning to really understand what is going
on in your code I am going to study it for awhile because I am sure I
can use the same concept elsewhere.
The concept of using an SQL statement to add a record to a
table is very useful, but only in limited situations. The
"normal" way to add a record is to let users do it through a
bound form.