473,466 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Need WorkAround: The expression you entered refers to an object that is closed or doesn't exist.

I understand why I am getting this error, I just need to find a work
around for it. Here is what I'm trying to do: There is a textbox on
my form that OnClick will ask the user for a new value, I want to take
this value and update the textbox with this value. I can't use the
recordsource option on this textbox because the Form ControlSource is
constantly changing. Here is the code I'm using:

Dim MyResponse As String
Dim MyNewVal As Currency
Dim Salary As Currency

MyResponse = InputBox("Enter a value of 1 or 2" & Chr(13) & "1) Enter
New Hourly Wage" & Chr(13) & "2) Enter a Salary", "New Rate")
Select Case MyResponse
Case "1"
MyResponse = InputBox("Input your Hourly Rate", "New Rate")
If MyResponse <> "" Then
MyNewVal = MyResponse
lblRate.ControlSource = "=" & MyNewVal
lblRate.DefaultValue = MyNewVal
lblRate.Requery
End If
Case "2"
MyResponse = InputBox("Input a Salary", "Salary to Hourly")
If MyResponse <> "" Then
Salary = MyResponse
MyNewVal = CalcSalary(Salary)
lblRate.ControlSource = "=" & MyNewVal
lblRate.DefaultValue = MyNewVal
lblRate.Requery
End If
End Select
If MyResponse <> "" Then
Call cmdCalc_Click
End If

This code works but it does not save the new value. It will work while
the form is in Normal View, but if I go to design mode or close it all
together the next time I open the form it reverts back to the original
value I typed in the Design Mode for this textbox. I need to come up
with a work around to have this textbox updateable with a value that
will be saved in the form and shows up the next time I open this form.

May 10 '06 #1
1 3200
ja*************@gmail.com wrote in
news:11**********************@u72g2000cwu.googlegr oups.com:
I understand why I am getting this error, I just need to find
a work around for it. Here is what I'm trying to do: There
is a textbox on my form that OnClick will ask the user for a
new value, I want to take this value and update the textbox
with this value. I can't use the recordsource option on this
textbox because the Form ControlSource is constantly changing.
Here is the code I'm using:

Dim MyResponse As String
Dim MyNewVal As Currency
Dim Salary As Currency

MyResponse = InputBox("Enter a value of 1 or 2" & Chr(13) &
"1) Enter New Hourly Wage" & Chr(13) & "2) Enter a Salary",
"New Rate") Select Case MyResponse
Case "1"
MyResponse = InputBox("Input your Hourly Rate", "New
Rate") If MyResponse <> "" Then
MyNewVal = MyResponse
lblRate.ControlSource = "=" & MyNewVal
lblRate.DefaultValue = MyNewVal
lblRate.Requery
End If
Case "2"
MyResponse = InputBox("Input a Salary", "Salary to
Hourly") If MyResponse <> "" Then
Salary = MyResponse
MyNewVal = CalcSalary(Salary)
lblRate.ControlSource = "=" & MyNewVal
lblRate.DefaultValue = MyNewVal
lblRate.Requery
End If
End Select
If MyResponse <> "" Then
Call cmdCalc_Click
End If

This code works but it does not save the new value. It will
work while the form is in Normal View, but if I go to design
mode or close it all together the next time I open the form it
reverts back to the original value I typed in the Design Mode
for this textbox. I need to come up with a work around to
have this textbox updateable with a value that will be saved
in the form and shows up the next time I open this form.

create a table. In the OnOpen event of your form dLookUp() the
value from this table. in the code which processes your user
inputs, update the value to this table.


--
Bob Quintal

PA is y I've altered my email address.
May 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: CLarkou | last post by:
On a client's machine with Office 97, my access program gives an error "The Expression you entered refers to an object that is closed or doesn't exist" when I am assigning a value in the checkbox....
14
by: John Temples | last post by:
Given this code: extern volatile unsigned char v; int main(void) { v; return 0; }
10
by: sandraz444 | last post by:
I have an expression in the query under my form to autofill the date under a certain condition but it wont write to the underlying table?? The date shows in the form but not the table. Does anyone...
21
by: Steven T. Hatton | last post by:
I'm trying to improve my formal understanding of C++. One significant part of that effort involves clarifying my understanding of the vocabulary used to describe the language. This is from the...
1
by: sumit205 | last post by:
Error 2467:The Expression you entered refers to an object that is closed or doesn't exist . DoCmd.OpenForm frm2, WindowMode:=acDialog, OpenArgs:="c" & NewProductID In the debig mode when i...
15
by: Jess | last post by:
Hello, Sometimes declarations are all what we need when we define/declare classes (or functions?), but sometimes we need definitions. I learned that if we define a class (B) that has an object...
6
by: weston | last post by:
In Access 2000 I have a form with a tab control with 3 tabs. I have a button that is supposed to check if each question on the form has been completed. The code that is under this button is below. It...
7
by: sdanda | last post by:
I am working on windows applications(VB.net). I created a form with a textbox and one button. I would like to test the value entered in the textbox after this textbox loses the focus. The value...
0
by: akshaycjoshi | last post by:
I am reading a book which says Even though unboxed value types don't have a type object pointer, you can still call virtual methods (such as Equals, GetHashCode, or ToString) inherited or...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.