Interpreting instructions frustration

BrianCambrian

Registered User.
Local time
Today, 02:05
Joined
Nov 11, 2014
Messages
10
Not sure if I am being stupid, I'm certainly struggling with Access.

One of the frustrating things I come across and I am sure other beginners must have come across similar is when you Google a question and you get answers that do not give a working example and don't actually make any sense. I will give an example:

I could not figure out the command to open a form using VBA code so I Googled the question 'access 2007 open form with vba'. The first link was to Microsoft's site which gave me the following:

The OpenForm method carries out the OpenForm action in Visual Basic.
Syntax
expression.OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)
expression A variable that represents a DoCmd object.
Followed by a list of optional parameters.

I tried putting the form name in Parentheses, in square brackets, in quotation marks and surrounded by nothing

After searching umpteen websites I discovered that the form name should be enclosed in quotation marks as well as parentheses. I see an example on the MS site but it uses only quotation marks and I found they don't work on their own, you need the parentheses as well.

This is extremely frustrating as I made numerous unsuccessful attempts before stumbling on the secret solution.

Am I just being thick ....?


regards


Brian

PS sorry for the rant so early in my membership of this forum as you guys have been very helpful so far and I don't want to upset anyone :)
 
Welcome to Google and the Internet. Results are not always clear, and not always relevant.

I used the SEARCH on this site with "OpenForm example"
http://www.access-programmers.co.uk/forums/showthread.php?t=271039&highlight=OpenForm+examples

The search gives a reasonable list -
see the link in http://www.access-programmers.co.uk/forums/showpost.php?p=1393460&postcount=4

Google tries to make sense of the terms you use -- try different words...

Here are a couple of sites for general access reference:
datawright and techonthenet

re OpenForm
http://www.datawright.com.au/access_resources/access_docmd.openform_arguments.htm

http://www.techonthenet.com/access/forms/dialog.php
 
Thanks for that. However, every example in your links uses quotation marks without parentheses and yet when I tried it I need both. Any idea why?

BTW that last link is particularly useful for something I want to do so thanks for that too.

regards

Brian
 
Can you post an example that you have that didn't work?

Most of the time you don't need the parentheses, you normally only need them if the command / function is used on the right hand side of an expression. A good example is msgbox;
To just open a message box in vba you use
Code:
MsgBox "Message here", vbInformation, "Title Here"
However if you want a response returned you need the parentheses
Code:
iResponse = MsgBox("Message here", vbYesNo, "Title Here")
 
within vba, a value is either a text string or a variable.


so this tries to open a form called "form1"

docmd.openform "form1"

whereas this

docmd.openform form1

looks for a variable called from1, and opens whatever that value is.

pretty well everything in vba works like this, when you thing about it. The only difference (I think) is that after a ! symbol you can refer to specific fields without the "" characters, which must be to do with the way the compiler treats the !character.

the arguments to docmd, and most other commands do not need to be enclosed in brackets, and enclosing them in brackets subtly changes them, although it rarely matters.

so docmd.openform "form1" and
docmd.openform ("form1") are practically identical, but ...
 

Users who are viewing this thread

Back
Top Bottom