Skip to content

Tag: vba

Populate listbox from access file

I have found a piece of code that enables me to list or populate listbox based on access database When trying that I encountered an error Type data mismatch in criteria expression at this line rst.Open strSQL, cnn, adOpenKeyset, adLockOptimistic, adCmdText Answer Your table got a field related to a secondary …

How to retrieve data from other Excel using VBA and SQL?

I have a problem with my code. I tried retrieving data from other Excel file. My code works but I received full data in one cell (A1). I’m sorry but I’m just beginner, believe that’s the problem related to output, but I’m not find out why: Answer No need to wrap recordset values wtih s…

Microsoft Access “User-defined type not defined”

When trying to run the following code, I’m getting an error when it hits Dim qdf As QueryDef saying User-defined type not defined I think it’s really weird because I have a backup of this same project in which not many changes were made after it which is working completely fine for this. I’v…

Return a string using the month part of a date field

I am trying to create a query which populates the salesPeriod field from the salesDate field. The query should return a string value based on the date part of the salesDate. The conditions are: If month is equal to equal to 11, 12, 1, return “Christmas Sales” If month is equal to 6,7,8 return &#82…