Submit Button query

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
767
Office Version
  1. 365
Platform
  1. Windows
Good morning,

I think this is a simple one, but it is a bit early for me this morning.

I am trying to add a userform to an Access database table which I have, but how do I add a if query to give me an outcome to add in in.
I need to be able to submit an answer based on if the dates are higher/lower as per below.

Code:
.Fields("Worked By") = Worksheets("Calcs").Range("B7").Value
.Fields ("When Keyed") = (DTPicker1 = DTPicker2,"Same Day Booking",if(DTPicker1 < DTPicker2,"In Advance","After Booking")

All help appreciated
thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Here are at least 3 ways. The first is easier to read IMO.

VBA Code:
With .Fields("When Keyed")
    If DTPicker1 = DTPicker2 Then
        .Value = "Same Day Booking"
    ElseIf DTPicker1 < DTPicker2 Then
        .Value = "In Advance"
    Else
        .Value = "After Booking"
    End If
End With

.Fields("When Keyed") = Choose(DTPicker1 = DTPicker2, "Same Day Booking", DTPicker1 < DTPicker2, "In Advance", True, "After Booking")
    
.Fields("When Keyed") = IIf(DTPicker1 = DTPicker2, "Same Day Booking", IIf(DTPicker1 < DTPicker2, "In Advance", "After Booking"))
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,824
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top