473,586 Members | 2,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why can't this unbound control be changed?

Hi.

I cannot change the value of an unbound control (txtSR and txtSS) within
a sub call. I explain ... my sub (SRSS_set) takes the date (type date)
as input, and returns 2 values (type time).

Public Sub SRSS_set(varDat e As Variant, _
varSR As Variant, _
varSS As Variant)

varSR = DLookup(...)
varSS = DLookup(...")

End Sub

Now, when I call this sub from the main module, the values of the 2
unbound controls don't change:

Call SRSS_set(Me!txt Date.Value, Me!txtSR.Value, Me!txtSS.Value)

However when I exchange the 2 unbound controls inside the sub call by 2
variables type variant, it works!

Call SRSS_set(Me!txt Date.Value, Test1, Test2)
Me!txtSR.Value = Test1
Me!txtSS.Value = Test2

Why does the first solution not work?

TIA

--
Georges

Nov 12 '05 #1
2 1695
It is because the parametes are passed to the sub by value, not by reference.
I think it would be most efficient to pass Me to the function by
reference (declare it as "Byref ParentForm as Form") and then
dereference the two controls inside the sub.

Pavel

Georges Heinesch wrote:

Hi.

I cannot change the value of an unbound control (txtSR and txtSS) within
a sub call. I explain ... my sub (SRSS_set) takes the date (type date)
as input, and returns 2 values (type time).

Public Sub SRSS_set(varDat e As Variant, _
varSR As Variant, _
varSS As Variant)

varSR = DLookup(...)
varSS = DLookup(...")

End Sub

Now, when I call this sub from the main module, the values of the 2
unbound controls don't change:

Call SRSS_set(Me!txt Date.Value, Me!txtSR.Value, Me!txtSS.Value)

However when I exchange the 2 unbound controls inside the sub call by 2
variables type variant, it works!

Call SRSS_set(Me!txt Date.Value, Test1, Test2)
Me!txtSR.Value = Test1
Me!txtSS.Value = Test2

Why does the first solution not work?

TIA

--
Georges

Nov 12 '05 #2
Hi.

1. ByRef is default, hence if I don't specify it, it's used. But to
doublecheck, I set it, and it still doesn't work.

2. To show that ByRef is not necessary, the second solution works [ Call
SRSS_set(Me!txt Date.Value, Test1, Test2) ]. In this case, variables are
used instead of the value of the control (first solution).

Why is this code not working when the control.value ist used?

TIA

--
Georges

Pavel Romashkin wrote:
It is because the parametes are passed to the sub by value, not by reference.
I think it would be most efficient to pass Me to the function by
reference (declare it as "Byref ParentForm as Form") and then
dereference the two controls inside the sub.

Pavel

Georges Heinesch wrote:
Hi.

I cannot change the value of an unbound control (txtSR and txtSS) within
a sub call. I explain ... my sub (SRSS_set) takes the date (type date)
as input, and returns 2 values (type time).

Public Sub SRSS_set(varDat e As Variant, _
varSR As Variant, _
varSS As Variant)

varSR = DLookup(...)
varSS = DLookup(...")

End Sub

Now, when I call this sub from the main module, the values of the 2
unbound controls don't change:

Call SRSS_set(Me!txt Date.Value, Me!txtSR.Value, Me!txtSS.Value)

However when I exchange the 2 unbound controls inside the sub call by 2
variables type variant, it works!

Call SRSS_set(Me!txt Date.Value, Test1, Test2)
Me!txtSR.Valu e = Test1
Me!txtSS.Valu e = Test2

Why does the first solution not work?

TIA

--
Georges


Nov 12 '05 #3

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

Similar topics

3
6328
by: Pat | last post by:
Hello, I've used Sum() to total bound fields on a continuous form with no problem. However, I now have a continuous form, on which I use an unbound field to calculate the number of hours between two times stored in a record (bound fields). This field is called txtDuration. On my footer, I've created another unbound field named...
3
2351
by: Trevor Hughes | last post by:
I am trying to resolve a problem I'm experiencing in Access 2000. I have an unbound control which is set be code on the open event of a form. However when I try to subsequently run some code which references the value in the unbound control, the code cannot see the value set. If however I manually type in the value into the unbound control...
1
2607
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that person’s name in a label control of a second unbound form. I have a scheduling program that I am working on. Included in the application program is a data “GRID” which I believe was created using Visual Basic, not standard Access. Its purpose is to display...
13
1982
by: PW | last post by:
Hi, This is bizarre. I've check and rechecked the spelling, cut and paste the name of the form (when trying to rename the form) and the control yet I still get a parameter prompt when the form runs. I've even deleted the control and started over. This is the code for the recordsource of the form: "SELECT * FROM...
5
2649
by: SBC News Groups | last post by:
Using VBA how do I assign columns from a table to controls on an unbound form? Mike
1
7425
by: sklett | last post by:
I've got a strange situation here. I have a databound DataGridView that also has un-bound columns. When the view loads, I want to update the values of the unbound columns. If I attempt to modify the unbound column's cells in the OnLoad() handler the results are very strange. If I add a button to my view and update the unbound cells in the...
8
3263
by: mlwerth | last post by:
Dear Access Group: This is the most basic and most embarrassing of questions, but I cannot find where to change the data type of a text field that I have in Access 2003 to a number field. I've searched high and low through help databases and on the internet. The directions say to : Open the table in Design view Click the Data Type...
3
2453
by: E. Kwong | last post by:
I have a DropDownList which is originally bound to a SqlDataSource. In Design view, the control is shown as "Databound". Later I changed my mind and changed the dropdown binded to a datatable programmatically. In Design view, the control is shown as "Unbound". The poblem is: after the change, the SelectedIndexChanged event no longer...
11
5152
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command button will open a new form (Form2). Form2 has two subforms. Both are embedded in the main form. (Subform2 is NOT embedded in subform1.) Subform1...
0
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8215
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.