473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

how to pass an old value field to another form

Hello,

Could you help me please? I have a problem with a if sentence and a query: I need to pass the POSITION.OldValue to another form but it is getting the new value instead.Thank you.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Position_BeforeUpdate(Cancel As Integer)
  2.  
  3. Dim str As String
  4.     If Me.POSITION.OldValue <> Me.POSITION.value Then
  5.  
  6.             str = "INSERT INTO tbl_GCDS_Operations_Positions_fills " _
  7.                & "([REPLACEMENT FOR],[POSITION],[POSITION NAME],[Snr Dir],[UNIT],[REPLACEMENT LAST DATE],[CompanyStartDate],[Position Status]) VALUES " _
  8.                & "('" & Me![NAME] & "','" & Me![POSITION] & "','" & Me![POSITION] & "','" & Me![Reporting Level 1] & "','" & Me![Group] & "','" & Me![Leave Date] & "','" & Me![Company Start Date] & "','" & "Open" & "'); " _
  9.             'Debug.Print str
  10.             CurrentDb.Execute str
  11.     End If
  12.  
  13. End Sub
  14.  
Apr 30 '18 #1

✓ answered by twinnyfo

ivon,

I would declare a form-specific variable strText, and then in the OnEnter Event, add similar code like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtTest_Enter()
  2.     strText = Me.POSITION
  3. End Sub
Then, use that variable as the "Old Value".

Keep in mind that it looks like you may have simply named a text box the same name as the underlying field. In which case, Access will automatically default to the value of the underlying field and not the value in the control on the Form. This is why I encourage all folks to use a good naming convention with their controls.

Hope this hepps.

1 1432
twinnyfo
3,653 Expert Mod 2GB
ivon,

I would declare a form-specific variable strText, and then in the OnEnter Event, add similar code like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtTest_Enter()
  2.     strText = Me.POSITION
  3. End Sub
Then, use that variable as the "Old Value".

Keep in mind that it looks like you may have simply named a text box the same name as the underlying field. In which case, Access will automatically default to the value of the underlying field and not the value in the control on the Form. This is why I encourage all folks to use a good naming convention with their controls.

Hope this hepps.
Apr 30 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: vishal | last post by:
hi i am using get method to pass data from one form to another and my value may contain & symbol. so when this is case the value after & sign is truncated which is logically true. so what...
4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
5
by: Bernard Davis | last post by:
Hi, I need to pass the value held in a field in one form and have it appear in another form. I specifically don't want to have to refer to the original form name as it has passed, because I...
7
by: Boki | last post by:
Hi All, I can't pass data to another form: in form2: private void button1_Click(object sender, EventArgs e) { Form1 form_copy = new Form1();
4
by: bluepiper | last post by:
Im using VB 6.0 The problem is have two forms the the first one (name it Form1) include one textbox control and button , and when pressing button I want to pass the textbox value to another text...
1
by: kunohiko | last post by:
Greets all... need help on reading value from another form under the same project. for example, i have frm1 and frm2, in frm2, i gotta use back the frm1.txtbox1.text value, how should i handle...
5
by: prasannagodbole67 | last post by:
IN c# : how to get value from another form .......................................... In 1st form there is a textBox that textbox value i want to another form in label.......
4
by: Parul Vinod | last post by:
In my project, i need to use a textbox value in another form, so how to make it global?
1
ahmedtharwat19
by: ahmedtharwat19 | last post by:
hi everybody i tied to pass value from subform to main form but it not work with me!! I need Send from subform to field in main form it work when i save the record in main form i need to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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,...
0
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
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...

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.