Vince
asked on
Set Default Values in Microsoft Access Table w/ VBA
With a Microsoft Access Form, I have 4 text boxes for the user to enter their Name, Department, Title, and Manager Name.
Using VBA, I want to take each of those 4 values and set the default values of 4 fields in a table. The form that opens up is not bound to the table for which I want to set up the default values for.
Using VBA, I want to take each of those 4 values and set the default values of 4 fields in a table. The form that opens up is not bound to the table for which I want to set up the default values for.
OR ... just
Me.Text1 = "YourDepartmentName"
and so on ... if you just want to hard code these values. The first post 'looks up' values from a table.
mx
Me.Text1 = "YourDepartmentName"
and so on ... if you just want to hard code these values. The first post 'looks up' values from a table.
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually, I am using ADO (which I forgot to mention in the original post). Here is a snippet of the ADO/SQL code that I used to accomplish this task.
Dim str1 As String
Dim strDblQuote1 As String
Dim strDblQuote2 As String
strDblQuote1 = """"
strDblQuote2 = """"
str1 = "ALTER TABLE StartingNumberTable ALTER COLUMN [LeadAuditor] CHAR (50) Default " & strDblQuote1 & strLeadAuditor & strDblQuote1
cnCon.Execute str1
Dim str1 As String
Dim strDblQuote1 As String
Dim strDblQuote2 As String
strDblQuote1 = """"
strDblQuote2 = """"
str1 = "ALTER TABLE StartingNumberTable ALTER COLUMN [LeadAuditor] CHAR (50) Default " & strDblQuote1 & strLeadAuditor & strDblQuote1
cnCon.Execute str1
vfinato
For future reference, next time try to explain a little better what you are trying to do ... and more importantly, please take the time to response to Expert comments. I took the time to give you two solutions and you gave No response.
mx
For future reference, next time try to explain a little better what you are trying to do ... and more importantly, please take the time to response to Expert comments. I took the time to give you two solutions and you gave No response.
mx
Anyway ... you can use DLookup() to do this ... and probably in the Form Load event, or possibly from a New Record button ...
Me.Text1 = DLookup("[Field1]","[YourT
mx