co12001 FAQ: Andrew Cumming

The following are the answers to some frequently asked question regarding Access arising from the co12001 RAD module.

I get the following error message when I click on one of my buttons: The expression On Click you entered as the event property setting produced the following error: Invalid outside procedure.
* The expression may not result in the name of a macro, the name of a user-defined function or [Event Procedure].
* There may have been an error evaluating the function, event or macro.
A common cause of this is a serious syntax error in your VB code.
The code window for the form should consist of a sequence of routines such as:
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click


    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command6_Click
End Sub
Every Private Sub should be completed with an End Sub. If a syntax error crops up outside one of these Sub Routines then the interpreter cannot find the right sub routine at run time. This results in the rather misleading error message shown.

What to do about it

Page up to the top of the Form Code page. At the top of the code page you should see something like
Option Compare Database
Option Explicit
in blue. Delete anything else that does not occur with a Sub definition.
Access 2000 and 97 on the same machine? See microsoft
Where do I start? Start with the output! Writing applications to enter data is the hardest part of many projects, leave it till the end.
  1. Get the design right (define tables, fields, relationships)
  2. Put in test data "by hand"
  3. Produce the outputs you want (reports and forms)
  4. Now you can worry about the data input
How can I put pictures in? You can dump pictures on a form, use Internet Explorer to find the image you want. Right click on the picture and "Copy". Open the form in design view and paste.
Not like that! How do I put pictures in a database? To put pictures in a table you add a field of type "OLE Object" - you can then paste images into individual records. You will need to view the table in design view to add a field.
So how do I make these images show up on the form? Open the form in design view, find the "Field List" and drag your new field onto the form.
How do I put sound clips in a database? I have never done this - but I would try the the same thing as above.
How do change the mouse pointer as it drifts over various parts of the form? I don't know - I suspect it is not possible. I would appreciate any advice on this.
How do I loop through a table when programming in Access 97? To get to the tables you need to obtain a "recordset" for the table. A recordset is a cursor - it points to a particular row, you can read and write individual fields and move the cursor through the table. The following will set the first name of all students to "Bruce". student is a table, FirstName is a field of the table.
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("student")
While Not rs.EOF
  rs.Fields("FirstName") = "Bruce"
Same thing in Access 2000
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "student", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
While Not rs.EOF
  rs.Fields("FirstName") = "Bruce"
Set rs = Nothing
How do I make and HTTP request from Access
Dim x As New WinHttpRequest
x.Open "POST", "", False
x.Send "r=2&s=Andrew wasn't here" & vbCrLf & "and here as well&p=howdee"
MsgBox x.Status
MsgBox Left(x.ResponseText, 500)
Before using WinHttpRequest you must first select Microsoft WinHTTP services from Tools / References in the Code Window
How do publish my Access data on the web? You use ASP. You will need an account on a machine which runs an IIS or PWS. If you have Windows 98 you already have PWS on your CD - this can be useful for development work. You can open a free account at Brinkster that will do the business.
How to prompt for a file name?
  • Put the common dialog control on your form - from the toolbox pick "... More Controls" and look for "Microsoft Common Dialog Control"
  • Let's suppose it is called commonDialog1.
  • Right click to set the properties such as filter.
  • commonDialog1.ShowOpen ' Make it go
    f = commonDialog1.FileName
    To see other stuff press F2 in code window to see the Object Browser and browse MSComDlg