Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Registration Seminar Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
ChatGPT said this
Jeffrey Nabarek 
      
2 years ago
Currently my Return code generator is doing a Msgbox,

I tried ChatGPT with the following question:

how do I get a variable to write to a field in Access VBA

It came up with the following code:

DetailsSub UpdateFieldUsingSQL()
    Dim db As DAO.Database
    Dim strSQL As String
    Dim myVariable As String
    
    ' Assign a value to the variable
    myVariable = "New Value"
    
    ' Set the SQL statement to update the field
    strSQL = "UPDATE MyTable SET MyField = '" & myVariable & "' WHERE SomeCondition = True"
    
    ' Run the SQL query
    DoCmd.RunSQL strSQL
End Sub


Explanation:
- MyTable: The table you're updating.
- MyField: The field you're updating.
- myVariable: The value you're setting the field to.
- SomeCondition = True: A condition to specify which records to update.
Make sure that if you're dealing with text fields, you properly enclose string variables in quotes (').

Is there an easier way of doing this?  It very confusing.
Alex Hedley  @Reply  
           
15 months ago
Take a step back and think about what you are actually trying to an achieve.

You want to store some information in a Table.
Have you done this before?
You create a Table with the Fields you need.
You bind a Form to that Table.
When you open that Form you can manually enter data into the Form and Save as you would usually.

Do that first.
Jeffrey Nabarek OP  @Reply  
      
15 months ago

Jeffrey Nabarek OP  @Reply  
      
15 months ago
I need to get the number 10126158 into the keycodein1 field.  That is my goal.  Can you tell me how to do that?  Thank you Alex.
Kevin Robertson  @Reply  
          
15 months ago
KeyCodeIn1 = Key1
Alex Hedley  @Reply  
           
15 months ago
How do you think you would set a Field on a Form in code?

Forgot about the calculation part at the moment.
Just create a Button that sets KeyCodeIn1 to a hardcoded value like "A".

Can you get that to work?
Jeffrey Nabarek OP  @Reply  
      
15 months ago

Jeffrey Nabarek OP  @Reply  
      
15 months ago
Kevin and Alex. I put this code in.  " KeyCodeIn1 = Key1"  If I press the "ok" it puts the code in the Keycodein1 field.

I thank you both.  May God Bless both of you and your families.   This is a major happening.  I can take it from here.  I want to close this blog  I got both your paypals address.  I will tip you.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Registration Seminar Lessons.
 

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 11:11:41 AM. PLT: 1s