Re: linking databases
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Mon, 21 Aug 2006 17:24:07 -0400
"Kevin" <Kevin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E0717AF5-37EE-4065-BB60-1D0C547F83CB@xxxxxxxxxxxxxxxx
Sub Country_OnExit
Dim sSQL as String
sSQL = "UPDATE [ctbto table 1] SET " & _
" [Region] = '" & Me.chrRegion & "', " & _
" [Country] = '" & Me.chrCountry & "'" & _
" WHERE [ID] = " & Me.dtmID & ";"
DoCmd.SetWarnings False
CurrentDb.Execute sSQL
DoCmd.SetWarnings True
End Sub
However, I'm quite obviously still doing something wrong and
misunderstanding how this code is supposed to work as when I run it, it
deletes the entry on the form in the first database for the particular
country whose record I want to update, while not updating the second
table.
I've also tried using the "After Update" event property and deleting the
"On
Exit" event property in the code, but then I get compile errors.
Not sure I see how that could delete any entries from a database.
Yes, if you point to the wrong table, and that wrong table happens to have
fields named "Region" and "Country", you'd end up overwriting the record
that has that ID, but an Update statement cannot delete data.
Also, how do I let Access know where to find the relevant table in the
second database? I've tried linking that table but to no effect. Please
bear
with me here, I'm really not very proficient with SQL and VBA programming
though I'm trying to learn them. I hope you can understand my explanation
and
can tell me what I"m doing wrong.
You could use an IN clause:
sSQL = "UPDATE [ctbto table 1] " & _
"IN C:\Folder\File.MDB " & _
" SET [Region] = '" & Me.chrRegion & "', " & _
" [Country] = '" & Me.chrCountry & "'" & _
" WHERE [ID] = " & Me.dtmID & ";"
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
.
- 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
- From: Douglas J. Steele
- Re: linking databases
- From: Kevin
- Re: linking databases
- Prev by Date: Re: Import and 2G limit
- Next by Date: Re: Importing Data
- Previous by thread: Re: linking databases
- Next by thread: Re: linking databases
- Index(es):
Relevant Pages
|
Loading