Re: linking databases
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Sat, 19 Aug 2006 09:11:00 -0400
What's the exact code you're using, then (since what you posted before
doesn't have the brackets around the table name)?
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Kevin" <Kevin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5056EEF4-994B-4D68-A4BD-6598F5711394@xxxxxxxxxxxxxxxx
Hi, thanks for answering.
Yes, 'ctbto table 1' is the name of the 2nd table I want to update. I've
already tried putting in the brackets but I just get the same error
message
for the whole name, i.e. '[ctbto table 1]'. I've also tried putting in an
underscore between the 3 parts of the table name and I still get error
messages. What could I do?
"Douglas J. Steele" wrote:
It would appear that the name of your table is ctbto table 1, which has
blanks in it. Whenever table or field names have blanks, they must be
enclosed in square brackets:
sSQL = UPDATE [ctbto table 1] SET " & _
" [Country Code] = '" & Me.Country Code & "', " & _
" [code] = " & Me.code & " " & _
" WHERE [ID] = " & Me.ID & ";"
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Kevin" <Kevin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8C2DAC16-9E77-47BC-8283-BA9B95C79520@xxxxxxxxxxxxxxxx
Hi,
Thanks for your reply. I've looked for code to execute an Update Query
and
found the following:
"So lets assume you have two textboxes txtAA and txtBB and you want to
save
their values in a second table tblBBB. Note that I will assume that AA
is
a
String/Text and BB is a number.Lets say the Primary key used in the
form
and
table tblBBB is called [PkID] in tblBBB and txtPkID on the form
Sub txtBB_OnExit
Dim sSQL as String
sSQL = UPDATE tblBBB SET " & _
" [AA] = '" & Me.txtAA & "', " & _
" [BB] = " & Me.txtBB & " " & _
" WHERE [PkID] = " & Me.txtPkID & ";"
DoCmd.SetWarnings False
CurrenDb.Execute sSQL
DoCmd.SetWarnings True
End Sub
You will need to rebuild this based on you actual fields and textbox
names."
I've rebuilt the code in the following way:
Dim sSQL As String
Sub ctbto table 1_OnExit
sSQL = UPDATE ctbto table 1 SET " & _
" [Country Code] = '" & Me.Country Code & "', " & _
" [code] = " & Me.code & " " & _
" WHERE [ID] = " & Me.ID & ";"
DoCmd.SetWarnings False
CurrenDb.Execute sSQL
DoCmd.SetWarnings True
End Sub
However, when I enter the name of the 2nd table (ctbto table 1) I get
an
'Expected: End of Statement' error message.
I've tried to contact the person who wrote this code, but do you know
why
I'm getting this error message and how I could correct it?
Thanks much in advance.
"Rick Brandt" wrote:
Kevin wrote:
Thanks for your reply! On one of the databases (the one I'm
building,
the other was done by another person) I actually do updates with
forms. I've done this using a command button which uses a macro to
open a form which I further filter using an SQL statement. So if I'm
looking a record for say "Canada" i have command button which when
clicked on opens a form for "Canada" where editing of that record
can
be done (I've locked the main form already so no editing can be done
there) I'm not very profficient with code though. Would you be able
to suggest code to me that I could use to update 2 or even more
databases using forms?
The simplest method would involve using the AfterUpdate event of your
form
to execute an update query against the other table. That update could
use
the record just saved to update the other table.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
.
- Follow-Ups:
- Re: linking databases
- From: Kevin
- Re: linking databases
- References:
- Re: linking databases
- From: Rick Brandt
- Re: linking databases
- From: Rick Brandt
- Re: linking databases
- From: Kevin
- Re: linking databases
- From: Douglas J. Steele
- Re: linking databases
- From: Kevin
- Re: linking databases
- Prev by Date: Re: Access Default database folder keeps changing to Program Files
- Next by Date: Re: Type Conversion Failure with dates
- Previous by thread: Re: linking databases
- Next by thread: Re: linking databases
- Index(es):
Loading