Subject: function calls
Posted By: ricmar Post Date: 9/23/2004 6:03:41 PM
I am trying to fix some VB code and I am a bit confused with the different ways of function calling.  

Example:

Call appendClause ("[Run Date]", frm!cboTestNumber, pre, post, STRNG)

or

Call appendCause ("Purpose", frm!cboRunPurpose, pre, post, STRNG)

if you notice, one call has brackets and the second call does not???


what is the difference????

Thanks



Reply By: jmaronilla Reply Date: 9/24/2004 12:34:52 AM
ricmar,
In visual basic codes when you have a string/text with a space between
characters for the code to work you need [] before and after the string/text.  Like in your example the Run Date doesn't need
a pair of brace when it is Run_Date.
I hope this helps.
john

Reply By: SerranoG Reply Date: 9/24/2004 6:54:40 AM
The brackets are used around a field name.  For example, if you're using a DLOOKUP function then it'd look something like this:

strString = DLookUp("[strMyField]", "tblMyTable", "[lngRecNo] = " & _
   Me.txtRecNo)

The first quote is a field name of strMyField located in a table called tblMyTable.  The second quote is the name of a table called tblMyTable in the database.  The third quote is a field named called lngRecNo in the table called tblMyTable.

Generally for DLookUp, DCount, or in SELECT statements, [] denote a field name.

The other use is when a field name or control element in your form or report has a space in it (a no-no).  For example, suppose you put a textbox on a form and called it My Text Box instead of MyTextBox.  In VBA code, you'd refer to it like this

If IsNull(Me.[My Text Box]) Then

instead of

If IsNull(Me.MyTextBox) Then


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply By: ricmar Reply Date: 9/24/2004 9:15:26 AM
Thanks guys this helped...


Go to topic 18761

Return to index page 765
Return to index page 764
Return to index page 763
Return to index page 762
Return to index page 761
Return to index page 760
Return to index page 759
Return to index page 758
Return to index page 757
Return to index page 756