473,761 Members | 3,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Codes when field1 is changed, field2 will change to =field1

Problem #1:

I have a form, which says, has 2 fields: F1 & F2 (both Dates). I want
to be able to change F1 and F2 will change to be the same as F1 in the
codes. However, I will still be able to change F2 at anytime if needed
and changes in F2 will not affect F1.
Problem #2:

How to set default value of F1 to stay the same as the value of F1 in
previous record until otherwise changed manually?
Thanks in advance,
Perry

Nov 13 '05 #1
5 1434
#1. In the AfterUpdate event of the first control, set the value of the
second control to the first one.

Example:
Me.txtF2 = Me.txtF1

Or, if you want the value that was in F1 to be "moved" to F2
Me.txtF2 = Me.txtF1.OldVal ue

#2. In the AfterUpdate event of the control, set the control's Default Value
to the current value of the control.

Example:
Me.txtF1.Defaul tValue = Me.txtF1

This will set the default value to the last value entered into txtF1. It
won't set it each time you move from record to record.

--
Wayne Morgan
MS Access MVP
<pe******@yahoo .com> wrote in message
news:10******** **************@ z14g2000cwz.goo glegroups.com.. .
Problem #1:

I have a form, which says, has 2 fields: F1 & F2 (both Dates). I want
to be able to change F1 and F2 will change to be the same as F1 in the
codes. However, I will still be able to change F2 at anytime if needed
and changes in F2 will not affect F1.
Problem #2:

How to set default value of F1 to stay the same as the value of F1 in
previous record until otherwise changed manually?
Thanks in advance,
Perry

Nov 13 '05 #2
Wayne,
This is what I had, but it does not seem to refresh. I even added
the line Me.Refresh but still none. Please advice again.

Private Sub SOCDate_AfterUp date()
Me.Date2 = Me.Date1

End Sub
Sincerely,
Perry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
> Private Sub SOCDate_AfterUp date()
Me.Date2 = Me.Date1
It appears that the name of the control is SOCDate, not Date1. Make the same
correction for Date2.

--
Wayne Morgan
MS Access MVP
"Perry Cheng" <pe******@yahoo .com> wrote in message
news:41******** **************@ news.newsgroups .ws... Wayne,
This is what I had, but it does not seem to refresh. I even added
the line Me.Refresh but still none. Please advice again.

Private Sub SOCDate_AfterUp date()
Me.Date2 = Me.Date1

End Sub

Nov 13 '05 #4
Sounds like the names of your controls in your code are wrong. You
want F2 to be the same as F1 whenever F1 is changed, so assuming on
your form, you need the following code:

Private Sub SOCDate_AfterUp date()
Me.Date2 = Me.SOCDate
End Sub

the above line containing Date2 will need to be changed to whatever
you named the 2nd date field on the form - also double check the
SOCDate name - i'm just going by what you posted. This should solve
your problem. I'm suprised you didn't get a method or data member not
found error when trying to update the fields. Me.refresh isn't
needed. Post back if you still have problems.

I have a form, which says, has 2 fields: F1 & F2 (both Dates). I want
to be able to change F1 and F2 will change to be the same as F1 in the
codes. However, I will still be able to change F2 at anytime if needed
and changes in F2 will not affect F1.
Perry Cheng <pe******@yahoo .com> wrote in message news:<41******* *************** @news.newsgroup s.ws>... Wayne,
This is what I had, but it does not seem to refresh. I even added
the line Me.Refresh but still none. Please advice again.

Private Sub SOCDate_AfterUp date()
Me.Date2 = Me.Date1

End Sub
Sincerely,
Perry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #5
Thanks guys, I figured it out now. What happened was I had an onclick
event to open up a calender, then by pick a value on the calender, it
was sent back to the SOCDate (which I renamed it here for simplicity
sake, but then, I forgot to change the event name! Sorry) By doing so,
it did not update Field2 even SOCDate changes... anyway, I had to ask
the pop up calender to send the value to SOCDate and then setfocus on
Field2 instead.

Thanks again.
Perry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #6

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

Similar topics

6
46910
by: Matthew Louden | last post by:
The following ASP code yields the following error, but actually the new record is stored in database. The same error happens when the application deletes a record, such as sqlStmt ="delete from test where username='2323'" Any ideas? Thanks! <% Dim objRS, sqlStmt Set objRS = Server.CreateObject ("ADODB.Recordset") sqlStmt = "insert into test VALUES ('2341', '2341');"
1
1561
by: radha | last post by:
--Table Create table tableName (Field1 int, Field2 int) Table Data Field1 Field2 1 10 2 10 3 10 1 20 2 20
2
1521
by: GGerard | last post by:
Hello I have the following tables joined on a one (Field4) to many (Field3) relationship Table1 Field1 / Field2 / Field3 1 Bob 2 2 Fred 4 3 Paul 2
7
1839
by: Miguel Dias Moura | last post by:
Hello, I am working in ASP.net / VB with Access Database. i have a Multipage in my web site with the Submit button as the last button. When the Submit button is pressed i want the form values to be added to a database and sent by email. 1. I have the code which submits the form values to the database. (See at
3
2754
by: AH | last post by:
Hi all, I noticed this strange behavior; I created a new control (example inherits from textbox) and add a new property, then I bind this new property to a field in my dataTable in a dataSet. After the binding statement, when I check for dataset.getchanges ... it alway returns that there is changes (even the propety just set the value and get the same value to return)... I have tried to understand what has changed by using the...
3
1180
by: Gustaf | last post by:
I have a class that I need to adapt to various scenarios. Some properties and methods will be needed in every case, while other's are unique for one case. So I made a base class, and a set of other derived classes for each scenario. But I don't understand this fully. There are not only methods in my original class. It has data too, in private fields. public class OriginalClass {
2
1335
by: eurolinux | last post by:
I'm trying to left join a table where there are two identical fields I want to select all records in a field from the left table and only those records from the identical field of the right table which are not bigger or smaller then 1 both field in the tables are integer data type Can someone help
2
1302
by: Gasnic | last post by:
Hi I need to create a .NET object that will be serialized into the following xml structure ( I can't change the XML schema) <Root> <Record> <Field1>data1</Field1> <Field2>data2</Field2> <Record> <Record>
5
5951
by: =?Utf-8?B?SGVyYg==?= | last post by:
I need a Table object in my RDLC with 6 columns on the top several rows, but 1 column on the bottom two rows: COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5 COLUMN6 COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5 COLUMN6 COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5 COLUMN6 -----------------------COLUMN1----------------------------------------- -----------------------COLUMN1----------------------------------------- I was able to acheive...
0
9538
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9353
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10123
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9975
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9788
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8794
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6623
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2765
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.