Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: Adding New Record To Form Using Junction Table

Started 1 month, 3 weeks ago by Kevsim
I have a table called Fix and another called Documentation. These 2 tables are connected to each other through a junction table which has the keys FixID and DocumentationID. There is a form called Fix, the form works well with all the Fix controls, add new record, edit record etc. I have added a combo box called Documentation (to update the Documentation table) along with all the Fix controls....
Site: Tek-Tips Forums  Tek-Tips Forums - site profile
Forum: Microsoft: Access Forms  Microsoft: Access Forms - forum profile
Total authors: 2 authors
Total thread posts: 9 posts
Thread activity: no new posts during last week
Domain info for: tek-tips.com

Other posts in this thread:

randy700 replied 1 month, 3 weeks ago
Have you tried an append query? CODE Dim strSQL As String strSQL = "INSERT INTO tblDocumentation(Key) VALUES(" strSQL = strSQL & Me.Key & ") DoCmd.RunSQL strSQL Randy

Kevsim replied 1 month, 3 weeks ago
randy700' Thanks for the info. Where the code states "Key", what values do I put in there? Also to explain a little further, Table T_Fix has FixID and some other foreign keys, Table T_Link has FixID and DocumentationID only, Table T_Documentation has DocumentationID only. I would appreciate some more information. kevsim

Kevsim replied 1 month, 3 weeks ago
randy700', One other thing. I am using a combo box to add the Documentation. kevsim

randy700 replied 1 month, 3 weeks ago
Replace "Key" in my code with the name of the key field in your table. Me.Key signifies the control on the form that is bound to the key field in your query/table. You can continue to add more fields as necessary, making sure you use the proper delimitors. Randy

Kevsim replied 1 month, 2 weeks ago
randy700, Thanks for the info provided. I have changed the code a little as I want to put a key value in each key field in the Junction table. When I run the code I receive an error "Run Time Error 3450, Syntax error in query, incomplete query clause" My code is as follows- strSQL = "INSERT INTO tblT_Junction.(FixID), tblT_Junction.(DocsID)VALUES(" strSQL = strSQL & Me.[Text188] & ")" & Me.[...

randy700 replied 1 month, 2 weeks ago
Add a comma... CODE strSQL = "INSERT INTO tblT_Junction.(FixID), tblT_Junction.(DocsID)VALUES(" strSQL = strSQL & Me.[Text188] & ") , " & Me.[Combo350] & ")" This assumes both fields are numeric. For text, you need to add single quotes... CODE strSQL = "INSERT INTO tblT_Junction.(FixID), tblT_Junction.(DocsID)VALUES( ' " strSQL = strSQL & Me.[Text188] & " ' ), ' " & ...

Kevsim replied 1 month, 2 weeks ago
randy700, Once more thank you for the help. I added the comma to the code but still receiving the same error. When holding the cursor over strSQL the second value was separated by a comma but did not have a leading bracket. I added a bracket after the comma and now both values are enclosed, I thought this may have been the problem, but still receiving the error "Run Time Error 3450, Syntax ...

Kevsim replied 1 month, 2 weeks ago
randy700, Thank you for all your help, success at last. I have corrected the SQL statement, I had the table mentioned twice in INSERT INTO and I had to remove the middle brackets between text and combo boxes. Find revised code - strSQL = "INSERT INTO T_Junction(FixID,DocsID)VALUES (" strSQL = strSQL & Me.[Text188] & "," & Me.[Combo350] & " );" DoCmd.RunSQL strSQL All working OK. kevsim

 

Top contributing authors

Name
Posts
Kevsim
6
user's latest post:
Adding New Record To Form Using...
Published (2009-11-09 23:55:00)
randy700, Thank you for all your help, success at last. I have corrected the SQL statement, I had the table mentioned twice in INSERT INTO and I had to remove the middle brackets between text and combo boxes. Find revised code  - strSQL = "INSERT INTO T_Junction(FixID,DocsID)VALUES (" strSQL = strSQL & Me.[Text188] & "," & Me.[Combo350] & " );" DoCmd.RunSQL strSQL...
randy700
3
user's latest post:
Adding New Record To Form Using...
Published (2009-11-09 12:15:00)
      Add a comma... CODE strSQL = "INSERT INTO tblT_Junction.(FixID), tblT_Junction.(DocsID)VALUES(" strSQL = strSQL & Me.[Text188] & ") , " & Me.[Combo350] & ")"    This assumes both fields are numeric. For text, you need to add single quotes... CODE strSQL = "INSERT INTO tblT_Junction.(FixID),...

Related threads on "Tek-Tips Forums":

Related threads on other sites:

Thread profile page for "Adding New Record To Form Using Junction Table" on http://www.tek-tips.com. This report page is a snippet summary view from a single thread "Adding New Record To Form Using Junction Table", located on the Message Board at http://www.tek-tips.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity