Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Insert or Update VBA
Bob Wolinski 
     
3 years ago
I am having trouble with and INSERT or UPDATE SQL statement in vba where I want to populate an expense table for trade show attendance  from a travel table where the users input their travel information and expenses. I don't want them to input the data twice.
Richard Rost  @Reply  
          
3 years ago
Hi Bob. "Having trouble" doesn't tell us anything. Show us what you've got.
Bob Wolinski OP  @Reply  
     
3 years ago
Sorry.  Frustration showing....
I have the data being entered in to Table one named, TradeShowTravelDataT  that I need to get in to auto populate into Table Two, TradeShowExpenseT.  I want it to be able to INSERT OR UPDATE if the data was already inserted into table two.
The Tradeshow ExpenseT will also have entries made directly for things unrelated to travel expenses.
What I need is a safe way to UPDATE the data if the record already exists, for let's say the price changed for the airfaire.  and append the data if it does not, like a new entry.   I have primary keys and foreign keys set up.  

TradeShowTraveDataT             TradeShowExpenseT

TSTravelDataID  primary key    to TSTravelDateID  as foreign key
TSID                                      to  TSID  
TSTravelbookedDate                 to TSExpenseDate
TStravelExpensePaidTo             to TSExpenseTo
TSTravelBookedBy                   to TSExpenseby
TSTraveExpense                      to  TSExpenseAmount

The TradeShowExpenseT has a primary key as well as an auto number


Richard Rost  @Reply  
          
3 years ago
I wouldn't use two tables to store essentially the same thing. Use one table and indicate the type of expense it is. Travel could be an option.
Bob Wolinski OP  @Reply  
     
3 years ago
I didn't explain my self properly.  I'm sorry.  The travel table has 12 more fields, and the ezpense table has one more what I listed is just where they overlapped.
Thanks for your replies however.
Richard Rost  @Reply  
          
3 years ago
I would still put that data in a single table. Its OK if there are some fields that one "type" needs that the other doesn't. It would be like having separate order tables for computers and televisions. They're both products that you sell. Sure, there may be SOME different fields for each, but a lot of overlap.
Scott Axton  @Reply  
        
3 years ago
Late to the party here but watch the Too Many Tables video.
This explains how to add in data for certain types.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 5:09:41 AM. PLT: 1s