I want to be able to extract values from a field if they meet a certain criteria. These extracted values would then populate a different field. How can I accomplish this? Thanks.
I want to be able to extract values from a field if they meet a certain criteria. These extracted values would then populate a different field. How can I accomplish this? Thanks.
Are you trying to take values from one field in a table and put them into a field in another table?
From one field in a form to another field in a form
Are both Forms open at the same time?
Sorry for not being clearer....both fields are in the same form.
What action on your Form do you want to be the action that causes the value from one field be appllied to the other field?
Eg:
Say you have two fields on your Form named Field1 & Field2.
Then let's say you have a command button called 'cmdUpdate'.
If you type a value into Field1 and click cmdUpdate - the value from Field1 will show up in Field2.
In order to do this - you can put this code behind your command button.
Code:Private Sub cmdUpdate_Click() Dim strField1 As String Me.Field1.SetFocus strField1 = Me.Field1.Text Me.Field2.SetFocus Me.Field2.Text = strField1 End Sub
Awesome! I'd like to be able to apply this to all the previous records in a one-time execution of the code. Would I just delete the button afterwards?
Wait.
Are you trying to change data in the Table behind the Form so that two different fields in the Table have the same data??
Trying to extract values that meet a certain criteria to be placed in another field on the form.
Where are all the previous records stored?I'd like to be able to apply this to all the previous records in a one-time execution of the code.
The Form only 'displays' the data.
Last edited by Robeen; 09-23-2011 at 12:57 PM. Reason: Incomplete.
In a table the form is based off of. But can I just extract the data from one field to populate another field I create on the form?
Would it be easier to make the change at the table/query level???
Yes you can do this automatically so that every time you move to a new record on the Form - the value from Field1 is applied to Field2.
Is your Form showing 1 record at a time? Or is it in Datasheet View?
If you only want to display the same thing twice on the Form - but not change anything in the Table . . .
I think the easiest way to do this is:
The field in which you want to display the duplicate value from Field1:
make its 'Control Source' Property - Field1.
Then it will show the same thing.
Or - if you want to get 'fancy':
Create a query based on your Table so that it has all the fields that you are using on your Form.
The field 'DuplicateField' will have the same Value as Field1.Code:Select Field1, Field2, Field3 . . . DuplilcateField: [Field1] From TableName
Save your Query.
Now go to your Form and change the Record Source Property of the Form to the query you just created.
Now - when you run the Form - the Field on your Form that you link to 'DuplicateField' from your Query - will always show the same value as Field1.
Just shows one record at a time.
To summarize:
The form has a field called "Preferences:". If the data contained in that field matches a list of about 5 different values, i want those values to be extracted from that field and placed in a new field. If the data does not match my criteria nothing happens. Would this be an easier fix at the table/query level?
Can you give me a simple example with data?