Re: Scripting conditional list box
- From: Vella <Vella@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Sep 2006 04:41:01 -0700
Hiyas John,
I did everything you said, right down to matching fields meticulously. For
some reason, the drop down box(ATime) won't populate. I wonder if the
Appt_Date field needs to be forced into Table1 before this will work? (or
does this happen dynamically?)
I'm a bit weary of adding any more script but I will have to add worker ID
to this as well. *sigh* I wish I knew where I was going wrong.
"J. Goddard" wrote:
Hi Vella -.
You said this:
> I realized this had to be a VB code so I put this in under form
properties
> (code builder) as an On Focus for the list box ATime. ...
I'm not sure what you mean by "Form Properties ... as On Focus for the
list Box", but I think you just did not word it right. Anyway, try this:
In the properties for the List Box, put this code in the "on Got Focus"
event. The code SQL = .... has to be all on one line - your browser is
probably wrapping it so it looks like it is on several lines:
'========
Dim SQL as string
SQL = "SELECT ApptTime FROM AppointmentTimes WHERE ApptTime not in
Select Table1.Appointment_Time from Table1 where Table1.Date = #" &
me!Date & "#)";
me!atime.rowsource = sql
'========
Replace AppointmentTime with the name of the table containing the list
of times
Replace ApptTime with the name of the time field in that table (DON'T
call it "Time")
Replace Table1 with the name of your table of Appointments
Replace Date in Table1.date with the dame of the Appointment Date field
(Dont call it "Date")
Replace Date in me!date with the name of the form control containing the
requested date (Don't call it "date")
Before closing the code window, from the Menu, click Debug - Compile.
Any errors?
John
P.S.
> ...I had set up a query called Time that executed when the list
> box was clicked on... this didn't really work as it popped up a box
asking for the date before the results populated the list box.
This might have been working, except that you called the query "Time".
Try renaming the query, because "Time" is an MS Access reserved word.
J
Vella wrote:
hiyas John,
ok. at first I had set up a query called Time that executed when the list
box was clicked on... this didn't really work as it popped up a box asking
for the date before the results populated the list box.
Then you gave me this code:
SQL = "SELECT ApptTime
FROM AppointmentTimes
WHERE ApptTime not in (Select
Table1.Appointment_Time from Table1 where
Table1.Date = #" & me!Date & "#)";
I realized this had to be a VB code so I put this in under form properties
(code builder) as an On Focus for the list box ATime. Still, it wouldn't
populate the list box. I have to wonder if I didn't use the wrong syntax?
This VB coding is a bit harsh for a newbie.
So, I think I might need a bit more explicit (read:) dummy proof instruction?
"J. Goddard" wrote:
Hi -
It sounds like you may be using the SQL statement in a db.execute or
docmd.runsql or something like that. Can you post your code to show how
you are using it, please?
Thanks
John
Vella wrote:
Thanks John,
ok...
I tried the statement that you provided and got an error "Invalid SQL
statement: expected 'DELETE', 'INSERT'...ECT."
So, I'm thinking I needed to deliniate something in there? Feeling rather
silly.
As far as employee, you are right, employee number would be best to negate
redundancies. So, If I check for the employee name and time, then this should
be a perfect statement for my needs. Only, Im feeling slightly lost now.
- References:
- Re: Scripting conditional list box
- From: J. Goddard
- Re: Scripting conditional list box
- From: J. Goddard
- Re: Scripting conditional list box
- From: Vella
- Re: Scripting conditional list box
- From: J. Goddard
- Re: Scripting conditional list box
- From: J. Goddard
- Re: Scripting conditional list box
- From: Vella
- Re: Scripting conditional list box
- From: J. Goddard
- Re: Scripting conditional list box
- From: J. Goddard
- Re: Scripting conditional list box
- Prev by Date: Re: Pictures and text in the butonn
- Next by Date: Re: Stop writing in a field
- Previous by thread: Re: Scripting conditional list box
- Next by thread: Too Many Dates
- Index(es):
Relevant Pages
|
Loading