Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 03-23-2019, 08:31 AM   #1
deltekkie
Newly Registered User
 
Join Date: Mar 2019
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
deltekkie is on a distinguished road
can't assign a value to this object

Hello,

I have a table that I am convert over for Excel which my group uses to track their work progress. I have created three particular fields in this table and linked a form to this table where they actually input the information. They input a start time and a stop time. I have three unbound text boxes as an experiment to test the VB math functions.

Table has
txtStartTime set to date/time
txtStopTime set to date/time
txtTimeSpent set to Short Text

Form has
table txtStartTime set to plain text bound to table StartTime
user will input this value

table txtStopTime set to plain text bound to table StopTime
user will input this value

table txtTimeSpent set to plain text bound to table TimeSpent
will receive value from calc2

txtCalcBox set to plain text is unbound
DayCalc set to plain text is unbound
calc2 set to plain text is unbound

This code will run
Me.txtCalcBox.Value = Me.txtStopTime.Value - Me.txtStartTime.Value
Me.DayCalc.Value = (Me.txtCalcBox.Value) Mod 24
Me.calc2 = Me.DayCalc & " Days " & Me.txtCalcBox
Me.txtTimeSpent = Me.calc2

every time
the form is opened
OR
tbStartTime is updated
OR
tbStopTime is updated

The first three work just fine. The last one throws the error.

I have tried many iterations of the last line and none work
examples:
Me.txtTimeSpent = Me.calc2
Me.txtTimeSpent.Value = Me.calc2.Value
Me!txtTimeSpent = Me!calc2
Me![txtTimeSpent] = Me![calc2]
Me![txtTimeSpent].Value = Me![calc2].Value
Me.[txtTimeSpent].Value = Me.[calc2].Value

Can anyone tell me what I am doing wrong?

Thank you!

deltekkie is offline   Reply With Quote
Old 03-23-2019, 08:48 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,710
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: can't assign a value to this object

Hi. Welcome to the forum. I actually don't understand what you're doing but if you're doing Me.txtTimeSpent = Me.calc2, it sounds to me like you want to display the same exact information on two different places on your form. If so, have you tried? Me.txtTimeSpent = Me.DayCalc & " Days " & Me.txtCalcBox
__________________
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
Old 03-23-2019, 10:40 AM   #3
deltekkie
Newly Registered User
 
Join Date: Mar 2019
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
deltekkie is on a distinguished road
Re: can't assign a value to this object

Here is a pic of the way the form looks.
Attached Images
File Type: jpg form.jpg (102.6 KB, 25 views)

deltekkie is offline   Reply With Quote
Old 03-23-2019, 10:42 AM   #4
deltekkie
Newly Registered User
 
Join Date: Mar 2019
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
deltekkie is on a distinguished road
Re: can't assign a value to this object

Here is the actual VB code
Some of it is commented out because I was troubleshooting

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
'Forms!frmLogsTab!txtTimeSpent.Format = "mmm yyyy"
Me.txtCalcBox.Value = Me.txtStopTime.Value - Me.txtStartTime.Value
Me.DayCalc.Value = (Me.txtCalcBox.Value) Mod 24
Me.calc2 = Me.DayCalc & " Days " & Me.txtCalcBox
'Me.[txtTimeSpent].Value = Me.[calc2].Value
End Sub

Private Sub txtStartTime_AfterUpdate()
Me.txtCalcBox.Value = Me.txtStopTime.Value - Me.txtStartTime.Value
Me.DayCalc.Value = (Me.txtCalcBox.Value) Mod 24
' Me.calc2.Text = Me.DayCalc.Text & " Days " & Me.txtCalcBox.Text
'Me.txtTimeSpent.Text = Me.calc2.Text
End Sub

Private Sub txtStopTime_AfterUpdate()
Me.txtCalcBox.Value = Me.txtStopTime.Value - Me.txtStartTime.Value
Me.DayCalc.Value = (Me.txtCalcBox.Value) Mod 24
'Me.calc2.Text = Me.DayCalc.Value & " Days " & Me.txtCalcBox.Value
'Me.txtTimeSpent.Text = Me.calc2.Text
End Sub
deltekkie is offline   Reply With Quote
Old 03-23-2019, 10:36 AM   #5
deltekkie
Newly Registered User
 
Join Date: Mar 2019
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
deltekkie is on a distinguished road
Re: can't assign a value to this object

What you suggested is what I originally had in the code. I got the same error. That is why I started using the unbound text boxes to test the code. For some reason, there is something about the txtTimeSpent bound textbox that will not allow me to update that value with a formula.
deltekkie is offline   Reply With Quote
Old 03-23-2019, 11:12 AM   #6
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,710
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: can't assign a value to this object

Hi. You're saying you're using bound and unbound controls. Can you make manual changes to the bound textbox? Please try typing a valid entry into txtTimeSpent (assuming txtTimeSpent is the bound control) and let us know what happens.
__________________
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
Old 03-23-2019, 02:25 PM   #7
JohnF53
Newly Registered User
 
Join Date: Jul 2013
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
JohnF53 is on a distinguished road
Re: can't assign a value to this object

I think that having your code in the OnOpen event is causing the problem.
The Access Help for the Form.Open event:
"The Open event occurs when a form is opened, but before the first record is displayed."
... as I understand it that means that at the point where the OnOpen event is triggered there is no record yet available to be updated, hence the error.
If you move your code to the OnCurrent event that might do the trick.

JohnF53 is offline   Reply With Quote
Old 03-23-2019, 03:33 PM   #8
jdraw
Super Moderator
 
jdraw's Avatar
 
Join Date: Jan 2006
Location: Ottawa, Ontario, Canada;West Palm Beach, Florida
Posts: 12,220
Thanks: 91
Thanked 2,022 Times in 1,970 Posts
jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light
Re: can't assign a value to this object

Further to JohnF53's post
Or possibly on the click event of the Calc Time button.
__________________

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.
jdraw is offline   Reply With Quote
Old 03-23-2019, 05:57 PM   #9
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 1,050
Thanks: 10
Thanked 208 Times in 197 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: can't assign a value to this object

I've only ever come across this error if I attempted to set a value in a textbox that has an expression for its controlsource property; i.e. you can't set a value in a calculated control (one whose controlsource begins with = ). Since the picture doesn't show the word "Days" in TimeSpent field yet it appears there's an attempt to include that word, I'd say there's something that's not evident from the description of what's going on. If the control isn't a calculated one, then could it be that there's an attempt to enter text in what looks like a date/time field?
__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Old 04-01-2019, 04:14 PM   #10
deltekkie
Newly Registered User
 
Join Date: Mar 2019
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
deltekkie is on a distinguished road
Re: can't assign a value to this object

Thank you all for your suggestions. It is working now as intended. There must have been something messed up in the database structure. It should have worked as some of you described but it did not. Strange! I am now updating the elapsed time in the table from the form and without the extra text box. Thanks again!
deltekkie is offline   Reply With Quote
Old 04-02-2019, 07:48 AM   #11
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 5,710
Thanks: 57
Thanked 1,259 Times in 1,240 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: can't assign a value to this object

Hi. Congratulations! Glad to hear you got it going. 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
You can't assign a value to this object OBBurton Queries 3 08-15-2014 10:59 AM
You can't assign a value to this object tpuhlig Forms 7 06-08-2012 12:40 PM
You can't assign a value to this object abidshahzad4u Forms 1 04-05-2010 09:03 PM
Can't assign value to object BobMcL Forms 1 04-15-2006 12:44 PM
Can't assign a value to this object froggiebeckie Forms 1 03-27-2006 11:56 AM




All times are GMT -8. The time now is 12:15 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