Combobox with dates

VaYooper

New Member
Joined
Mar 12, 2015
Messages
31
I have a combobox in an access form that I want to pull in dates from a table. When I click on the dropdown for this combobox it is blank. Below are the pieces that relate to this dropdown. I assume it has something to do with the format. Is my problem that I'm declaring it as a string each time and it should be something else?


Private Sub cboLastLogin_AfterUpdate()
Dim myLogin As String
myLogin = "Select * from tbl_users where ([LAST_LOGIN] = '" & Me.cboLastLogin & "')"
Me.tbl_users_subform.Form.RecordSource = myLogin
Me.tbl_users_subform.Form.Requery
Me.cboUnitName = Null
Me.cboUserType = Null
Me.cboSSAAR = Null
Me.cboLastName = Null
End Sub


If IsNull(Me.cboLastLogin) Then
strLastLogin = "[LAST_LOGIN] like '*'"
Else
strLastLogin = "[LAST_LOGIN] = '" & Me.cboLastLogin & "'"
End If


Dim strUserType, strSSAAR, strLastName, strLastLogin, strUnitName As String
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Small edit.... I got the dates to populate within the combobox dropdown. But now when I select on a date I get Run-time error '3464': 'Data type mismatch in criteria expression'
 
Upvote 0
If [LAST_LOGIN] is a date/time data type try:

Code:
myLogin = "Select * from tbl_users where ([LAST_LOGIN] = #" & Me.cboLastLogin & "#)"

TIP: The delimiter for the date/time data type is #. Example: [LAST_LOGIN] = #3/16/2015#
 
Upvote 0

Forum statistics

Threads
1,221,900
Messages
6,162,691
Members
451,782
Latest member
LizN

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