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
|
|||
|
|||
Setting default value in textbox field on form
Hi NG,
I'm trying to set the default value in a Form Textbox by referring to a value stored in a table, but not having much luck with it. I've tried to enter this in the Default Value property: =Select TblUserSettings.ExportExcelPath from TblUserSettings where TblUserSettings.RowID="1" which doesn't work. Also tried =DLookup("[ExportExcelPath]"," TblUserSettings "," TblUserSettings.RowID=1") doesn't work either. What I have is: Table:TblUserSettings Field: ExportExcelPath Field: RowID And what I would like to be shown in the Form's textbox as default value is: Select ExportExcelPath from TblUserSettings where RowID = 1 Any suggestions for what would be the correct syntax is warmly welcome. - Chr |
#2
|
|||
|
|||
The SELECT statement won't work like that, but the DLookup() is pretty
close. How about doing that in the Open event procedure of your form, i.e.: Private Sub Form_Open(Cancel As Integer) Me.MyTextbox.DefaultValue = DLookup("[ExportExcelPath]", _ "TblUserSettings", "RowID=1") End Sub If that doesn't work, try adding extra quotes, as DefaultValue is a string setting: Me.MyTextbox.DefaultValue = """ & DLookup("[ExportExcelPath]", _ "TblUserSettings", "RowID=1") & """" -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Christian" wrote in message ... I'm trying to set the default value in a Form Textbox by referring to a value stored in a table, but not having much luck with it. I've tried to enter this in the Default Value property: =Select TblUserSettings.ExportExcelPath from TblUserSettings where TblUserSettings.RowID="1" which doesn't work. Also tried =DLookup("[ExportExcelPath]"," TblUserSettings "," TblUserSettings.RowID=1") doesn't work either. What I have is: Table:TblUserSettings Field: ExportExcelPath Field: RowID And what I would like to be shown in the Form's textbox as default value is: Select ExportExcelPath from TblUserSettings where RowID = 1 Any suggestions for what would be the correct syntax is warmly welcome. - Chr |
#3
|
|||
|
|||
Thanks!
I'll give it try - Chr |
#4
|
|||
|
|||
Hi,
I can't get it to work, still returns #name Can I just put the dlookup() in the default value for the field in the form? How should I write it? - Chr |
#5
|
|||
|
|||
got it working with this formula directly in the field.
DLookup("TblUserSettings.ExportExcelPath"; "TblUserSettings"; "TblUserSettings.RowID=1") - Chr |
#6
|
|||
|
|||
Christian,
I know you asked this question way back but hopefully you still will get my question. Could I use this example (changing it slightly of course) if I want to change or manipulate a forms control but by doing so from another form within the same database you think? Wayne "Christian" wrote: got it working with this formula directly in the field. DLookup("TblUserSettings.ExportExcelPath"; "TblUserSettings"; "TblUserSettings.RowID=1") - Chr |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
"SELECT" | REVBJONES | Using Forms | 18 | August 30th, 2004 04:47 AM |
dlookup | miaplacidus | Using Forms | 9 | August 5th, 2004 09:16 PM |
Textbox field, fill using query based on value of id field on form | Michael Miller | Using Forms | 0 | June 8th, 2004 06:31 PM |
Form Doesn't Go To New Record | Steve | New Users | 15 | May 16th, 2004 04:33 PM |