A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Referencing Another Table



 
 
Thread Tools Display Modes
  #11  
Old March 30th, 2007, 06:23 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Referencing Another Table

I just went in and pasted the SQL into the SQL View and switched back to the
Design view. Weird looking, but it runs fine. However, I don't see anyway to
create it.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in message
...
Gotcha. Can you do both flavors of append or insert into using the append
query design view in access or can only do the second flavor or insert
into
by hard coding it, can't use design view to do that?



Access calls it an Append query, but if you look at the SQL, it's "INSERT
INTO MyTable ...."

I don't really understand your point about needing a checker field.

There are 2 flavours for the INSERT INTO statement: one lets you specify
the
values, as opposed to selecting them from a table.

The equivalent to

Set MyDb = CurrentDb
Set MyRec = MyDb.OpenRecordset("Select * From SecondTable")
MyRec.AddNew
MyRec!Test = Me.Test
' You can add other field here in the same way
MyRec!KeyField = Me.KeyField
MyRec.Update

would be:

Dim strSQL As String

strSQL = "INSERT INTO SecondTable (Test, KeyField) " & _
"VALUES (" & Me.Test & ", """ & Me.KeyField & "")"
CurrentDb.Execute strSQL, dbFailOnError

(I've assumed Test is a numeric field and KeyField is a text field.
You'll
need to change the quotes if that's not the case.)

However, as I said, I think your approach should be fine.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in
message
...
When you say insert query, you mean append query right? But to be able
to
do
that, you have to create a field that will be checker, the one that is
required like yes/no, so you make that particular record to have that
field
say yes, so when you do the append, it only grabs that particular one.


I'd probably just run an Insert query, rather than opening the
recordset,
but it's not a big deal.

If you are going to open a recordset, though, it might be faster if
you
open
an empty one:

Set MyRec = MyDb.OpenRecordset("Select * From SecondTable WHERE
False")


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in
message
...
Woo hooo!!!!

Btw, from what I said, is this the best way to handle this, the
suggestion
in this post?








  #12  
Old March 30th, 2007, 06:43 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Referencing Another Table

I don't really understand what you're saying (and you're trimming far too
much from the posts, making it difficult for me to look back at what you
said you're trying to do).

What did you change the code to, and what exactly is it you want it to do?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in message
...
I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Mind putting that in code for me?

Thanks
Curtis



  #13  
Old March 30th, 2007, 07:00 PM posted to microsoft.public.access.forms
Curtis Stevens
external usenet poster
 
Posts: 231
Default Referencing Another Table

I tried to modify what you gave me:

Dim strSQL As String

strSQL = "INSERT INTO SecondTable (Test, KeyField) " & _
"VALUES (" & Me.Test & ", """ & Me.KeyField & "")"
CurrentDb.Execute strSQL, dbFailOnError

With this data:

I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) = EmailCreationsBody

Not working for me, can you plug it into your code you gave me?

Thanks
Curtis

I don't really understand what you're saying (and you're trimming far too
much from the posts, making it difficult for me to look back at what you
said you're trying to do).

What did you change the code to, and what exactly is it you want it to do?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in message
...
I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Mind putting that in code for me?

Thanks
Curtis




  #14  
Old March 30th, 2007, 07:19 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Referencing Another Table

I wanted to see what exactly you'd tried, and what you expected to see added
to your table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in message
...
I tried to modify what you gave me:

Dim strSQL As String

strSQL = "INSERT INTO SecondTable (Test, KeyField) " & _
"VALUES (" & Me.Test & ", """ & Me.KeyField & "")"
CurrentDb.Execute strSQL, dbFailOnError

With this data:

I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Not working for me, can you plug it into your code you gave me?

Thanks
Curtis

I don't really understand what you're saying (and you're trimming far too
much from the posts, making it difficult for me to look back at what you
said you're trying to do).

What did you change the code to, and what exactly is it you want it to
do?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in
message
...
I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Mind putting that in code for me?

Thanks
Curtis






  #15  
Old March 30th, 2007, 07:36 PM posted to microsoft.public.access.forms
Curtis Stevens
external usenet poster
 
Posts: 231
Default Referencing Another Table

I tried

Dim strSQL As String

strSQL = "INSERT INTO FollowUpNotes(Subject, EmailCreationsBody) " & _
"VALUES (" & Me.Subject& ", """ & Me.EmailCreationsBody& "")"
CurrentDb.Execute strSQL, dbFailOnError

I was expecting the same, whatever data is in me.emailcreationsbody, I want
it inserted into a new record in Followupnotes table in the subject field of
that table.

I tried switching subject/emailcreationsbody around & nothing.

Curtis



I wanted to see what exactly you'd tried, and what you expected to see added
to your table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in message
...
I tried to modify what you gave me:

Dim strSQL As String

strSQL = "INSERT INTO SecondTable (Test, KeyField) " & _
"VALUES (" & Me.Test & ", """ & Me.KeyField & "")"
CurrentDb.Execute strSQL, dbFailOnError

With this data:

I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Not working for me, can you plug it into your code you gave me?

Thanks
Curtis

I don't really understand what you're saying (and you're trimming far too
much from the posts, making it difficult for me to look back at what you
said you're trying to do).

What did you change the code to, and what exactly is it you want it to
do?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in
message
...
I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Mind putting that in code for me?

Thanks
Curtis






  #16  
Old March 30th, 2007, 07:43 PM posted to microsoft.public.access.forms
SusanV
external usenet poster
 
Posts: 399
Default Referencing Another Table

Not trying to butt in, just watching...
Noticed you're using double quotes inside your VBA. Try singles instead:
"VALUES (" & Me.Subject& ", '" & Me.EmailCreationsBody& "')"

--
hth,
SusanV

"Curtis Stevens" wrote in message
...
I tried

Dim strSQL As String

strSQL = "INSERT INTO FollowUpNotes(Subject, EmailCreationsBody) " & _
"VALUES (" & Me.Subject& ", """ & Me.EmailCreationsBody& "")"
CurrentDb.Execute strSQL, dbFailOnError

I was expecting the same, whatever data is in me.emailcreationsbody, I
want
it inserted into a new record in Followupnotes table in the subject field
of
that table.

I tried switching subject/emailcreationsbody around & nothing.

Curtis



I wanted to see what exactly you'd tried, and what you expected to see
added
to your table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in
message
...
I tried to modify what you gave me:

Dim strSQL As String

strSQL = "INSERT INTO SecondTable (Test, KeyField) " & _
"VALUES (" & Me.Test & ", """ & Me.KeyField & "")"
CurrentDb.Execute strSQL, dbFailOnError

With this data:

I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Not working for me, can you plug it into your code you gave me?

Thanks
Curtis

I don't really understand what you're saying (and you're trimming far
too
much from the posts, making it difficult for me to look back at what
you
said you're trying to do).

What did you change the code to, and what exactly is it you want it to
do?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in
message
...
I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Mind putting that in code for me?

Thanks
Curtis








  #17  
Old March 30th, 2007, 07:46 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Referencing Another Table

If all you want is to insert a single value into FollowUpNotes, you probably
only need

strSQL = "INSERT INTO FollowUpNotes(Subject) " & _
"VALUES (""" & Me.EmailCreationsBody& """)"
CurrentDb.Execute strSQL, dbFailOnError

(note that I was missing a quote in the original suggestion)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in message
...
I tried

Dim strSQL As String

strSQL = "INSERT INTO FollowUpNotes(Subject, EmailCreationsBody) " & _
"VALUES (" & Me.Subject& ", """ & Me.EmailCreationsBody& "")"
CurrentDb.Execute strSQL, dbFailOnError

I was expecting the same, whatever data is in me.emailcreationsbody, I
want
it inserted into a new record in Followupnotes table in the subject field
of
that table.

I tried switching subject/emailcreationsbody around & nothing.

Curtis



I wanted to see what exactly you'd tried, and what you expected to see
added
to your table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in
message
...
I tried to modify what you gave me:

Dim strSQL As String

strSQL = "INSERT INTO SecondTable (Test, KeyField) " & _
"VALUES (" & Me.Test & ", """ & Me.KeyField & "")"
CurrentDb.Execute strSQL, dbFailOnError

With this data:

I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Not working for me, can you plug it into your code you gave me?

Thanks
Curtis

I don't really understand what you're saying (and you're trimming far
too
much from the posts, making it difficult for me to look back at what
you
said you're trying to do).

What did you change the code to, and what exactly is it you want it to
do?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Curtis Stevens" wrote in
message
...
I tried your code, maybe I'm getting it backwards.

ControlName of Field in SecondTable = Subject

ControlName of Field in Main Table (what is being copied) =
EmailCreationsBody

Mind putting that in code for me?

Thanks
Curtis








 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:14 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.