Re: Change field value in table not in form record source
- From: "Carl Rapson" <mr.mxyzptlk@xxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Mar 2007 10:56:44 -0500
You're building the SQL string by concatenating the value from Box_Location
onto the rest of it. Any time you need to include the contents of a control
in a SQL string that's how you'll do it (in VBA code, anyway).
I'm glad it's working.
Carl Rapson
"WCDoan" <WCDoan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9486D73D-F97E-4F7D-9F06-31A8A2FE8456@xxxxxxxxxxxxxxxx
Carl,
That did it! Thanks so much. Somethign I don't understand is why you have
to have the quote and the ampersand before the Me.Box_Location. I thought
the
whole SQL statment had to be included in quotes, but this way it's just up
to
the equal sign. It's working like I want it too, but I was just curious as
to
why it's done the way it is. Anyhoo, thanks so much for your expert help.
RandyM
"Carl Rapson" wrote:
It depends on how you're setting the location in tbl-boxes. What are you
storing in tbl-boxes, Location-Key or Location-Number? What is in the
bound
column of your location combo box (Box-Location)?
Let's make some assumptions. You should be storing Location-Key in
tbl-boxes, so let's assume you are doing so. Furthermore, Location-Key
should also be the bound column on Box-Location, although you can show
only
Location-Number. If those assumptions are correct, then you would use:
UPDATE [tbl-location] SET [Location-Used]=True WHERE [Location-Key]="
&
Me.Box-Location
If the assumptions aren't true, maybe you can glean enough from this
example
to see what you need to change.
Carl Rapson
"WCDoan" <WCDoan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B071EC88-8F4F-48BF-805A-8B72A77C17F1@xxxxxxxxxxxxxxxx
Thanks for replying Carl. I'm not exactly sure what goes where. The
tbl-location table has 3 fields: Location-Key, Location-Number(it's
text),
and Location-Used. In the code you gave me- Location-Used would go
where
[Available] is? The combo box control is Box-Location would this be the
Me.txtLocation in the code? And would Location-Number go where
[location]
is
in the code. Unforturnately, where I work I wear several hats and so I
haven't had to do anything in Access in about 9 months so, as the old
saying
goes, "if you don't use it, you lose it." I've lost it. :) Thanks again
for
your help, I really do appreciate it.
RandyM
"Carl Rapson" wrote:
In the AfterUpdate event of the control that contains the location,
update
tbl-location with something like:
DoCmd.RunSQL "UPDATE [tbl-location] SET [Available]=False WHERE
[location]='" & Me.txtLocation & "'"
This assumes location is a text value (not numeric). Be sure to use
your
own
field and control names.
Carl Rapson
"WCDoan" <WCDoan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CA838C91-7882-47BC-9229-77FAD16FE9FD@xxxxxxxxxxxxxxxx
I'm not sure if my subject description explains what I need and not
sure I
can explain my problem clearly enough, but here goes. I have a form
that
has
1 table (tbl-boxes) as its record source. It has two other tables
that
are
used for look-ups in combo boxes (tbl-department and tbl-location).
The
tbl-location has a field in it that shows availablity. Once a
location
is
used I need to mark this location as unavailable by changing the
value
from
yes to no. How do I change the value in the other table that is used
for
look-up purposes? Will I have to add it to the form or is there
another
way?
This location problem arose after the form had been completed and is
an
afterthought that I have to now allow for, c'est la vie. :) Thanks
for
any
help anyone can give.
RandyM
.
- Follow-Ups:
- References:
- Re: Change field value in table not in form record source
- From: Carl Rapson
- Re: Change field value in table not in form record source
- From: Carl Rapson
- Re: Change field value in table not in form record source
- From: WCDoan
- Re: Change field value in table not in form record source
- Prev by Date: Re: Referencing Another Table
- Next by Date: Re: Updating Yes/No table field based after form input completed
- Previous by thread: Re: Change field value in table not in form record source
- Next by thread: Re: Change field value in table not in form record source
- Index(es):
Relevant Pages
|
Loading