Go Back   Access World Forums > Apps and Windows > Visual Basic

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-25-2019, 10:57 AM   #1
adidab14
Newly Registered User
 
Join Date: Apr 2019
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
adidab14 is on a distinguished road
Updating Record Through a Form

Hello there,
I am trying to update a record through a form based on an unbound text box and a null value but I'm having a little trouble getting the code to work. I'm hoping that someone here can help me.
Basically I'm looking to add a timestamp to a specific field (TimeOut) if the record contains the value in the text box AND a null value in the TimeOut field.

So my variables here are:
Table where all of this is found = Test
Field that needs to match the text box = MoldNumber
Text Box = txtMold
Field that I need updated if it has a null value = TimeOut.

Here's the code I'm trying but failing with:

Code:
CurrentDb.Execute "UPDATE Test SET TimeOut = #" & Now() & "# WHERE MoldNumber= '" & Me!TxtMold & "'", IsNull(TimeOut), dbFailOnError
I'm not terribly well versed in VBA but I just can't seem to figure this out. Any help would be greatly appreciated!

adidab14 is offline   Reply With Quote
Old 04-25-2019, 11:01 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 1,980
Thanks: 23
Thanked 506 Times in 495 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Updating Record Through a Form

Hi. You were almost there. I would try it this way:
Code:
Dim strSQL As String


strSQL = "UPDATE Test SET TimeOut=Now() WHERE TimeOut Is Null AND MoldNumber='" & Me.txtMold & "'"


Debug.Print strSQL


CurrentDb.Execute strSQL, dbFailOnError
Hope it helps...
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
adidab14 (04-26-2019)
Old 04-26-2019, 05:54 AM   #3
adidab14
Newly Registered User
 
Join Date: Apr 2019
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
adidab14 is on a distinguished road
Re: Updating Record Through a Form

That worked like a charm. You are amazing!

adidab14 is offline   Reply With Quote
Old 04-26-2019, 07:09 AM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 1,980
Thanks: 23
Thanked 506 Times in 495 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Updating Record Through a Form

Quote:
Originally Posted by adidab14 View Post
That worked like a charm. You are amazing!
Hi. Glad to hear it worked for you. Good luck with your project.

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating Record with form help Treefarn Forms 2 02-23-2015 04:44 PM
updating record via form help cyberpac9 Forms 0 08-08-2006 04:58 AM
[SOLVED] Help with record updating form!? Phoenix Forms 1 01-27-2006 01:11 AM
Updating Form's Record casey Forms 2 12-02-2002 08:46 PM
Problem .. Instead of updating the changed record..the form adds another like record dmeid Forms 6 11-20-2002 09:04 AM




All times are GMT -8. The time now is 12:27 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World