我有1个组合框和1个日期文本框。 我只想通过组合框创建动态日期文本框默认值,例如,当我在组合框中选择“自行车服务”时,日期文本框默认值将更改为“ Date()-Weekday(Date())+ 30”,如果我选择其他,例如CAR SERVICE,它将更改为“ Date()-平日(Date())+ 180”
Private Sub Form_Load() If CBO_SERVICE = "BIKE SERVICE" Then
TextDate.DefaultValue = "Date()-Weekday(Date())+30" End If End Sub
Private Sub CBO_SERVICE_Click() If CBO_SERVICE = "BIKE SERVICE" Then
TextDate.DefaultValue = "Date()-Weekday(Date())+30" End If End Sub
Private Sub CBO_SERVICE_Dirty(Cancel As Integer) If CBO_SERVICE = "BIKE SERVICE" Then
TextDate.DefaultValue = "Date()-Weekday(Date())+30" End If End Sub
没有显示错误,但是什么也没发生,请帮助
答案 0 :(得分:0)
您可以设置默认值-这是一个字符串-像这样:
Me!TextDate.DefaultValue = "#" & Format(DateAdd("d", -Weekday(Date) + 30, Date), "yyyy\/mm\/dd") & "#"