Forum

Forum (https://www.ms-office.gr/forum/)
-   Access - Ερωτήσεις / Απαντήσεις (https://www.ms-office.gr/forum/access-erotiseis-apantiseis/)
-   -   Ενημέρωση πεδίων σε νέα φόρμα, από υπάρχουσα (https://www.ms-office.gr/forum/access-erotiseis-apantiseis/6208-enimerosi-pedion-se-nea-forma-apo-yparxoysa.html)

Pettor 12-11-22 13:39

Ενημέρωση πεδίων σε νέα φόρμα, από υπάρχουσα
 
Hi guys, I would some help with the below.
I have a form, in which, the user enters some data and updates a table. This form opens through a button from a previous form where some specific data are retrieved and presented from a different table.
What I would like to do, is the empty form to get into some fields data from the previous form, by default, and then the user to fill in the rest by hand. After that, the whole record needs to be stored in a different table.
Since the form that needs to update the new table has a "recordset source" linked with the table that finally needs to get updated, I can not bring the data I want from the previous form that has the details that need to be autofilled.
So, to make the example realistic, let's say that I have a table with a list of houses and their addresses that is presented in a form.
I select one of them, and through a button, a new form opens with the data of a specific house.
Then I want a new button inside this last form to open a third form where some data will be auto-filled (let's say the address of the home) and the user will enter some additional info, with data irrelevant to the initial table, where the address is stored.
In the end, I want all of the data from the last form to be stored in a new table. Any opinions?
Thanks

tsgiannis 15-11-22 09:36

Hi
You need to work with the Current Event and some form variables
e.g
Κώδικας:

Option Compare Database
Dim someField as String
Dim someOtherField as Integer
..................

'Suppose you want to carry someField from a textbox named baseField
Private Sub baseField_AfterUpdate()
' Some Other Code
someField = Me.BaseField

End Sub

Private Sub cboOtherField_AfterUpdate()
'Some Other Code
someOtherField =Me.cboOtherField
End Sub

'Now on the Current Event
Private Sub Form_Current()
If me.NewRecord then
If Len(SomeField) then Me.BaseField = SomeField
If Len(SomeOtherField) then Me.cbOtherField = SomeotherField
End if
End Sub

Now the workflow goes like this :
You start entering data...the very first time you enter the data are stored in the form variables
Now on every new record the variables are carrying the values and they fill the controls with the default values...when you change some of the values this are updated on the form's variables and they are carried on the next new Record


Η ώρα είναι 12:14.

Ms-Office.gr - ©2000 - 2026, Jelsoft Enterprises Ltd.


Search Engine Optimization by vBSEO 3.3.2