Steve,
Can you help me with a similar problem? I took a class in VB but I'm
completely useless working in it. I haven't even thought about it for 6
years.
Anyway, I have a similar problem. I have a form with two different types of
data that can be entered: Lumpmisc Credits or Lump Sum Charges. There is a
combo box for each type of entry (multiple values for each one). I have a
field called "Adjustment Type" that I want to enter either "lm" or "ls"
depending on which type of adjustment is input. I understand I cannot use a
default value, so VB is the only option I see for this. Using what you gave
to DebsMo, I think I need something like this:
Private Sub Adj_Type_AfterUpdate()
If Me.[Lumpmisc Credit Codes] = " " Then
Me.[Lumpmisc Credit Codes] = "ls"
Else
Me.[Lumpmisc Credit Codes] = "lm"
End If
But, this doesn't work. How should I define the variable "Me.[Lumpmisc
Credit Codes]? Shoud it be something like 'Me.[Lumpmisc Credit Codes] =
Text'? "Lumpmisc Credit Codes' is the name of the field in which the user
would enter the type of adjustment. I want the form to enter "ls" if that
field is empty (meaning they entered a lumpsum instead of lumpmisc
adjustment) and "lm" if there is data in that field.
Steve Schapel said:
DebsMo,
You won't be able to use a Default Value for this purpose. The Default
Value is assigned at the point where a new record is started, and at
that point in your data entry, Access doesn't know the TaskType, so it
can't assign the TaskDueDate. You could, however, use a VBA procedure
on the After Update event of the control (combobox?) where you enter the
TaskType, something along these lines...
If Me.TaskType = "Set-Up" Then
Me.TaskDueDate = Me.EventDate
Else
Me.TaskDueDate = Null
End If
--
Steve Schapel, Microsoft Access MVP
I want to assign a default value based on a conditional expression. e.g. For
the textbox control [TaskDueDate] I want the default value to be calculated
as follows: =IIf([TaskType] = "Set-Up", [EventDate],Null) A default value is
never returned with this expression even when the [TaskType] = Set-Up.