Setup the Northwind dB

Northwind Database

I'm not sure when the Northwind database became available, but it seems to me like it's been around right from the beginning. I have blogged about the Northwind database several times on the Nifty Access Site…



See below for info on How to set Northwind up

Setup the Northwind Sample dB

Northwind Sample dB

Video 1 (1:20)

In this video I demonstrate how to install and setup the “Northwind Sample Database” from Microsoft. 

If you are interested in learning how to program MS Access with VBA then my “VBA Beginner – Nifty Access” playlist on YouTube might be a good start for you!

Find more Northwind Blogs in the Menu Below:-

Video 1 (1:20)

Nifty Access YouTube Thumb Nail

… …

More Useful Stuff HERE:-

TempVars Value Error

You cannot Always omit “Value”

I often see people are advised they do not need to refer to a Control’s Value implicitly like this:-

				
					Dim strValue As String
strValue = cboCurrent.Value
				
			

This advice is given because “Value” is the default, therefore it is unnecessary to append it, So you could write the above like this:-

				
					Dim strValue As String
strValue = cboCurrent
				
			

However this is not entirely true in Every case!

I noticed this “Unexpected behaviour” a few years back, when I tried to convert one of the Northwind database’s macro’s into a VBA routine. Some of the Northwind macros save information into TempVars. The conversion routine used the combobox name only, omitting the Value property and resulted in an Error.

I would guess it’s not widely known that by omitting the “Value” property when saving to TempVars causes the TempVar to assume you are trying to save an object to it, as most VBA programmers avoid useTempVars, and would seldom experience this problem.

You can reproduce this behaviour yourself:-

Try and add the value of a combobox to a TempVar with this Code:-

				
					TempVars.Add "CurrentUserID", cboCurrent
				
			

You will trigger the following error:-

Error 32538 —  TempVars can only store data. They cannot store Objects.

This is because the TempVar thinks you are trying to assign an object to it (the combobox) and not the value of the object (the combobox Value).

What’s interesting is, if you assign the combobox value to a string variable, (you can do this without appending the control name with the “Value” property) then you assign the string variable to the TempVar and it works fine:-

				
					Private Sub Command0_Click()
Dim strValue As String

strValue = cboCurrent

MsgBox " >>> " & strValue

TempVars.Add "CurrentUserID", strValue
End Sub
				
			

TempVars Value Error

TempVars Value Error

Video 1 (2:31)

I discovered a minor issue when converting a Macro to VBA code. You may have to include the “Value” Property for your text box or combo box (whichever control the the macro is associated with) – this seems a bit odd to a seasoned Microsoft Access programmer because the value property is normally a default and you don’t have to add it (Append it). However it causes a problem because if the macro code assigns a variable to one of the newfangled “TempVars” then for some reason these temporary variables can interpret the assignment as being an object and not text. This confuses the the newly created code, the code created by the Microsoft utility for converting macros into VBA. Running the newly created VBA code causes the following runtime error:- Runtime error 32538 – TempVars can only store data they cannot store objects.

Video 1 (2:31)

Nifty Access YouTube Thumb Nail

New Blog about "VALUE HERE:-

… …

Macro Conversion to VBA Causes Error

Macro Conversion to VBA Causes Error

Video 2 (5:15)

In the section of this video:- “Is this Control a Hyperlink – Nifty Access” starting at time index 2 minutes, (the video should automatically start at that time index due to the Marvellous features of Elementor!) I demonstrate the conversion of a Microsoft Access Macro into Microsoft Access VBA. The video utilises the free Northwind sample database provided by Microsoft. This is an excellent demonstration you can perform yourself once you have downloaded the Northwind sample database.

Video 2 (5:15)

Nifty Access YouTube Thumb Nail

… …

Access 2007 Login Form

Access 2007 Login Form

Video 3 (5:53)

The Northwind sample database provided by MS Access 2007 has been upgraded to demonstrate many of the new features available in MS Access 2007. In this video we take a look at the log-in form and the new MS Access 2007 tempVar…..

Video 3 (5:53)

Nifty Access YouTube Thumb Nail

… …

MS Access 2007 Login & TempVars 1

MS Access 2007 Login & TempVars

Video 4 (6:46)

In this video we take a look again at the log-in form and the new MS Access 2007 tempVar in more detail. The conversion from a macro into VBA wasn’t as good as I hoped, and left code with a requirement for some slight modifications which are shown in this video.

Video 4 (6:46)

Nifty Access YouTube Thumb Nail

… …

MS Access 2007 Login & TempVars 2

MS Access 2007 Login & TempVars

Video 5 (6:53)

I cant fathom out what the code in the after update event of the combo box is for. It appears to save the name of the combo box into the temporary variable, the temporary variable which contains the users record number from the user table, and then this number is used in later forms to identify the person taking the orders and other search admin functions.

Video 5 (6:53)

Nifty Access YouTube Thumb Nail

… …

Tidy up the Login Form

Tidy up the Login Form

Video 6 (2:22)

It’s always a good idea to tidy up your code and your forms as you go, and in this particular case, some code which is possibly redundant is commented out using a custom command bar and a buttons.

Video 6 (2:22)

Nifty Access YouTube Thumb Nail

… …

More Useful Stuff HERE:-

Import CSV

CSV Import

I’ve done quite a bit of research into importing Comma Separated value Files into MS Access. In particular, I’m working on importing CSV files with more than 255 columns. I have had a reasonable amount of success, but it was thwart with complications that were difficult to resolve. Not ready to release my results publicly, but if you want to contact me privately, I will happy to discuss it with you.

Import CSV into Staging Tables

Import CSV

Video 1 (2:15)

Import the Comma Separated Value file (CSV )into a staging table. Then run two queries against the staging table. One query to extract “H” into a new table, the other to extract “R” into a new table.

Video 1 (2:15)

More Info on Import CSV:-

… …

More Useful Stuff HERE:-

List Box Default Selection

List Box Default

Please be aware that while upgrading the Nifty Access Website I discovered this post. I tried to link it back to the original post on Access World Forums, however I couldn’t I find the post. I found one that looks similar, but I don’t think it is the correct one! I’m going to leave this post like it is for now and get back to it at a later date. Nothings wrong with the post other than the links back to the forum might not be correct… cheers Tony.

List Box Highlight a Default Selection 

List Box Highlight a Default Selection 

Video 1 (2:0)

This video is In answer to a specific question asked by Frank.

Frank Asked:- I need to select (highlight) the first item in a llstbox in order to ensure that a piece of code operates, but I cannot remember how to do this in code on the opening of the form obtaining the listbox. The form is called frmListRecd and the listbox is called lstRecd. Any help would be greatly appreciated.

Set the listbox controls default value so that the list highlights the same row …

Video 1 (2:0)

Nifty Access YouTube Thumb Nail

Access World Forums Post HERE:-

Highlight a Default Selection - Bullet Points

00:27 go to the list box properties
00:45 put something in the default value
00:47 a “2”
01:12 and you can see that item “2” is selected
01:26 the list box needs to be linked to a field in the underlying table
01:35 it won’t work if it’s not linked to a table because the value is not recorded (although I’m not sure that’s right!)

… …

More Useful Stuff HERE:-

Control Wizard (Access 2007)

Control Wizard

The Control Wizard is a very handy feature of MS Access. It provides built-in wizards, which simplify many of the processes you have to partake in to build your MS Access database.

Button Wizard (Access 2007)

Button Wizard (Access 2007)

Video 1 (2:09)

Demonstrate how to use the MS Access (2007) command button wizard to open another form and filter it to display the same record on the second form as you were looking at in the first form.

Video 1 (2:09)

Nifty Access YouTube Thumb Nail

… …

More Useful Stuff HERE:-

Enable or Disable a Text box

Enable or Disable by Command

In this video I demonstrate how to make a control appear greyed out. In other words, you can’t do anything with it. I demonstrate the process by using two separate command buttons, however it is possible to do it with a single command button. I have a video demonstrating this, however I couldn’t find it! Will post it here when I find it! If you need it, contact me and I will definitely find it for you!

Enable or Disable a Text box

Grey out a Text box in MS Access 

Video 1  (1:57)

I’ve done a quick and dirty video here showing how to enable or disable a text box just using a couple of command buttons.

Video 1  (1:57)

More Useful Stuff HERE:-

Reports Weaving Records

Report Tips

In this video I demonstrate how you can set up a two column report and have the records Weave to and fro across the Report. Open the report in “print preview” then select “page setup”, “columbs”, then select the column layout you prefer.

Multi Column Report - Weaving Records

Multi Column Report - Weaving Records

Video 1 (1:02)

More Info on Weaving Records:-

Video 1 (1:02)

Nifty Access YouTube Thumb Nail

… …

More Useful Stuff HERE:-

Show Table Structure to a Forum

Show Your Table on a Forum

Show Table Structure to a Forum.The best way is to provide a small sample database. You don’t need to provide your whole database. In fact by including too much information you just confuse the issue and make it difficult for anyone to help you.

Indeed if you just dump your monster dB on the Forum people will take one look and leave. You won’t get the help you expect. If your database is untidy, full of junk code, and generally slung together, why should anyone else try and sort it out for you…

All that is required is the Form that has the issue and the complementary table or tables related to the issue on that form, nothing else.

If your problem is in a module, then provide a brand new form to show the problem. If you are unable to supply a sample, then try the alternative(s) below which aren’t ideal, but better than nothing.

Table to a Forum

Video 1 (4:02)

To help someone to answer your Forum question, you’ve been asked to show more information about your “Table” structure. Here are several options you can use to extract and present the information to the forum…

Video 1 (4:02)

Nifty Access YouTube Thumb Nail

… …

More Useful Stuff HERE:-

Display Field Data Horizontally

Transform, Concatenate Examples

A common requirement in MS Access is to extract Columnar data into horizontal data, for instance to make reports look better, to provide a list of emails suitable to send to with Outlook. In the YouTube videos below I explain how this can be done.

Display Field Data Horizontally

Display Field Data Horizontally

Video 1  (4:53)

Good database design requires you to store your data Vertically. However it’s difficult to display this Vertical, columnar data in forms and reports. Also, in the case of an email list, you may need it convert it from the “Vertical” to “Horizontal” for use in VBA code to send multiple emails.

In this video I demonstrate how to extract this columnar data and concatenate it into a string suitable for these type of uses…There is enough information in the video for you to be able to reconstruct the demonstration yourself.

If you want to save yourself a bit of time, then by all means you can download the sample database for a small fee..

Video 1  (4:53)

Nifty Access YouTube Thumb Nail

VBA Code - Concatenate Email Addresses - Sample - From Video 1

				
					Public Function fConcatList()
Dim DB As DAO.Database
Dim RS As DAO.Recordset
    
Dim strSQL As String
Dim strText As String

strSQL = "SELECT tblContact.MailToHere FROM tblContact" 'This is just a query like you would build
                                                        'in the query builder, but it is in text format
Set DB = CurrentDb

    'Open a Recordset and loop through it to fill the text box txtTest
    
    Set RS = DB.OpenRecordset(strSQL, dbOpenForwardOnly)
    Do Until RS.EOF
            If strText = "" Then 'This If statment prevents a  single comma at the begining of the text","
                strText = RS!MailToHere
                Else
                strText = strText & ", " & RS!MailToHere
            End If
        RS.MoveNext
    Loop
    
    RS.Close
    Set RS = Nothing
    Set DB = Nothing

    fConcatList = strText

End Function      'fConcatList

				
			

… …

Complex Data Horizontally

Complex Data Horizontally

Video 2  (6:32)

In the above example “Display Field Data Horizontally” I demonstrate how to compile a list of email addresses which are displayed in a text box. The results could just as easily be passed to another function designed to email the list of clients stored in a table. It would also be possible to provide a query (as an SQL string) with a where clause, making it possible for you to email a subset of clients based on some sort of criteria.

It is always desirable to have the SQL Statement build itself as it were. In this Video “Complex Data Horizontally” I demonstrate how to build the SQL Statement with a WHERE clause that limits the records extracted using the batch number and serial number of the item. The item is a very sophisticated and expensive device somewhat similar to a mobile phone. You just could not manually create the necessary queries effectively.

In this YouTube I’m going to show you one way to go about this.

Video 2  (6:32)

Nifty Access YouTube Thumb Nail

VBA Code - Concatenate Repair Description - Sample - From Video 2

				
					Option Compare Database
Option Explicit

Const strSQLWhere As String = "SELECT tblUnitRepair.UnitRepairBatchNo, " & _
"tblUnitRepair.UnitRepairSerialNo, tlkpRepair.RepairDesc " & _
"FROM tlkpRepair INNER JOIN (tblUnitRepair INNER JOIN tblRepairLog " & _
"ON (tblUnitRepair.UnitRepairSerialNo = tblRepairLog.RepLogSerialNo) " & _
"AND (tblUnitRepair.UnitRepairBatchNo = tblRepairLog.RepLogBatchNo)) " & _
"ON tlkpRepair.RepairID = tblRepairLog.RepLogRepair " & _
"WHERE (((tblUnitRepair.UnitRepairBatchNo)="

Const strSQLAnd As String = "AND ((tblUnitRepair.UnitRepairSerialNo)="
Const strSQLOrder As String = "ORDER BY tlkpRepair.RepairDesc"
Const strSQLParenRHS1 As String = ") "
Const strSQLParenRHS2 As String = ")) "

Public Function fConList(intBatchNo As Integer, strSerialNo As String)
Dim DB As DAO.Database
Dim RS As DAO.Recordset
    
Dim strSQL As String
Dim strText As String

strSQL = strSQLWhere & intBatchNo & strSQLParenRHS1 & _
strSQLAnd & "'" & strSerialNo & "'" & strSQLParenRHS2 & strSQLOrder
Set DB = CurrentDb

    'Open a Recordset and loop through it to fill the text box txtTest with
    'the faults Repaired >>>reprorted by the customer<<<<
    
    Set RS = DB.OpenRecordset(strSQL, dbOpenForwardOnly)
    Do Until RS.EOF
            If strText = "" Then 'This If statment prevents a  single comma at the begining of the text","
                strText = RS!RepairDesc
                Else
                strText = strText & ", " & RS!RepairDesc
            End If
        RS.MoveNext
    Loop
    
    RS.Close
    Set RS = Nothing
    Set DB = Nothing

Let fConList = strText
End Function
				
			

… …

Posts Related to this Blog:-

The link(s) below relate to various discussion(s) related to this Blog.

Visit these and you may find someone else has already solved the problem you are having. You could also pose a new question to clarify the process of using this technique for concatenating vertical lists into a horizontal display of information.

… …

More Useful Stuff HERE:-

Easily Apply Filters

Filtering - MS Access Forms

This video should be of interest to anyone who wants to easily apply filters to an MS Access form in datasheet view or continuous form view. In this demonstration I show how you can apply filters in a Form presented in Continuous view and also in Datasheet view. When you apply the filters, they are actually added to the forms properties. By opening the Forms property sheet you can view the filter you have just created. The filter appears as a text string added to the filter property of the Form. Once you are aware of this nifty little trick that MS Access automatically does for you, then you can leverage it by copying the text version of the filter and use it in VBA code! It’s not 100-percent straightforward, and I show you one Gotcha and the solution… The solution is to change the double quotes within the filter to single quotes. You can use this filter string created by MS Access in your VBA code. Calling the VBA code which sets the filter from the onClick event of the label above the column. With this information you now have the ability to level up your display to something nice and professional looking. Got to be good for your kudos in your company!

ApplyFilter to Sub-Form

ApplyFilter to Sub-Form

Video 1  (5:31)

You will find more information related to this video in this thread on Access World Forums (AWF) here:- ApplyFilter to subform

Video 1  (5:31)

Nifty Access YouTube Thumb Nail

… …

More Useful Stuff HERE:-

This website uses third-party software - WordPress Add-Ins to be exact. I don't know what any individual add-in does, but I'm sure that many of them collect information about you. So be aware, if you continue using this site, then you are likely to be sharing your information. I don't know how to disable this sharing for any, or all of the plugins for individual users. So I can't stop the sharing of information. If this worries you then please do not use this site... If you continue to use this site I will assume that you are happy with it.

Do you need a hand in the right direction?

You are in the right place.