Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update/rreplace value of field from Form

Status
Not open for further replies.

nadir66

IS-IT--Management
May 30, 2002
34
0
0
Hi
For the last few hours i am trying to figure this out...
i have a form and on the form a field quantity, the same in the table inv_process. i need to have the users update this value, click or whatever.
i mean, they will see two textboxes, one shows the current value, the second is for the new value. user enters the value and saves.
pls help
nadir
 
Nadir
Just to check out what your situation is...

You have two text boxes on a form - let's call them txt1 and txt 2.

txt1 holds the current value of the inv_process field in the table
txt2 holds what will become the new value of the inv_process field

Correct?

Tom
 
Hi Tom
Yes, 2 textboxes. One is bound to the existing value the 2nd is empty.
 
Nadir
Okay, I'll have a look this evening. I had something similar a while ago. I'll look it up.

Tom
 
Nadir
Okay, here is what I did. See if this helps you.

1. To begin with, I made a small table with 3 fields - RecordID, Name, txt1. The latter field, txt1, is formatted as currency.

2. In the form, I put 4 fields - Name, Text1, Text2 and Text6.
Text1 has its control source as txt1 in the table, and holds the current value
Text2 is an unbound control and is to hold the new value
Text6 is an unbound control and is made invisible

3. In the form's Current event, I put this code...
Private Sub Form_Current()
If Me.NewRecord Then
Me.Text1 = Me.Text6
Me.Text2 = ""
End If
End Sub

4. In the forms BeforeUpdate event, I put this code...
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Text2 <> &quot;&quot; Then
Me.Text1 = Me.Text2
Else
End If
Me.Text6 = Me.Text1
End Sub

As you can see, Text6 is the key to the process, as it holds the value that will be placed in Text1 when there is a new record. It was the only way I could get it so the new value control, Text2, would go blank when there was a new record.

Hope this helps.
Tom
 
thx tom
i will give ot a try.
nadir
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top