Calendar displaying autonumber from a combo box..

dagsgaz

New member
Local time
Today, 09:29
Joined
Aug 23, 2024
Messages
2
Hi all,
First post here and very new to VBA so apologies in advance! I've tried searching on Google and also here and couldn't find much.
I have created a calendar using MS Access and VBA. I'm trying to get it to display holidays and what shift the person is on. My code almost works correctly...
Issue im having is that it displays the autonumber from the combo box. I've set the colums widths etc, and to view my tables and query it does display the name correctly.

"Fullname" is the name of the the fieldname that is displaying the number.

Code:
Sub DisplayBirthdaylist(dselectdate As Date, lcontrol As Control) ' This is the popup when cal dates are clicked
    Dim rst As Recordset
    Dim sql As String
    Dim sList As String
        
        sql = "select * from qryHolidays where Holday=" & Format(dselectdate, "dd") _
        & " and HolMonth=" & Format(dselectdate, "mm") & ";"
            
    Set rs = CurrentDb.OpenRecordset(sql)
        
    If rs.RecordCount > 0 Then
        rs.MoveFirst
        
        Do Until rs.EOF
        
            sList = sList & rs!Fullname & " - " & rs![Shift?] & vbCrLf
                      
            rs.MoveNext
        Loop
    End If
    
    Set rs = Nothing
    
    lcontrol.Caption = sList
 
Sounds like you are using a lookup field in your table

Remove the lookup and you will then see what you actually need for your sql
 
Sounds like you are using a lookup field in your table

Remove the lookup and you will then see what you actually need for your sql
Hi;

It is a lookup field, it’s submitted via a form where the operator can drop down a list, select there name and then Input the dates they are off.
 
Hi. Welcome to AWF!

Can you post a screenshot of your table in design view showing the properties screen of your lookup field?
 

Users who are viewing this thread

Back
Top Bottom