If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Default Value for a Text box field
It's something that's probably pretty simple for most... so I would
appreciate any help or guidance. I have a form with a number of fields. I'm using a dlookup function to bring in a value from another table based on what is entered in the fields above. If I put the dlookup function in the control source within the text box options, the right values come trough. My issue is that I want to edit those values. If I put the same code in the default within the properties, I either get an error, or nothing comes back. How could I be able to have the text box on the form populate automatically based on what's entered in previous fields, and then be able to change the value if I needed to. =DLookUp("[VendorName]","[MainTable]","[StoreNumber]=Forms![InvoiceTracking_frm]![StoreNumber]") |
#2
|
|||
|
|||
Default Value for a Text box field
On Wed, 13 Jan 2010 12:57:10 -0800, KM wrote:
It's something that's probably pretty simple for most... so I would appreciate any help or guidance. I have a form with a number of fields. I'm using a dlookup function to bring in a value from another table based on what is entered in the fields above. If I put the dlookup function in the control source within the text box options, the right values come trough. My issue is that I want to edit those values. If I put the same code in the default within the properties, I either get an error, or nothing comes back. How could I be able to have the text box on the form populate automatically based on what's entered in previous fields, and then be able to change the value if I needed to. =DLookUp("[VendorName]","[MainTable]","[StoreNumber]=Forms![InvoiceTracking_frm]![StoreNumber]") This will just display the looked-up value. Since you need to edit it (in this table, leaving it unchanged in the MainTable I presume!) you'll need to "push" it into the textbox. To do this you'll need to use the AfterUpdate event of (in this case, I'm guessing) the StoreNumber control. Something like Private Sub StoreNumber_AfterUpdate() If IsNull(Me!yourcontrolname) Then ' don't stomp on already entered value Me!yourcontrolname = DLookUp(... your expression above...) End If End Sub If you do want to overwrite the user entered value when a new store number is selected, omit the If and End If lines. -- John W. Vinson [MVP] |
Thread Tools | |
Display Modes | |
|
|