Is it possible to use a function within a message box? I want to show our current version number. For Example: MsgBox "Blah Blah Blah", vbOKOnly, "STracking fGetVerNo".
Is it possible to use a function within a message box? I want to show our current version number. For Example: MsgBox "Blah Blah Blah", vbOKOnly, "STracking fGetVerNo".
Sure. It would just be something like:
assuming that your function does not need any parameters and can run like that normally.Code:MsgBox "Blah Blah Blah", vbOKOnly, "STracking " & GetVerNo
Oh thank you. I am still doing something wrong. What I get is STracking & getVerNo. Just don't know the proper syntax I guess
JoeM has shown correct syntax. Note that the function call is not within quotes - it is concatenated. What are you doing different? Post your attempted syntax.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Ok. So I moved the Quotation marks, and now what I get is JUST STracking - nothing else. Maybe it is the function....?
MsgBox "Blah Blah Blah", vbOKOnly, "STracking " & getVerNo
Maybe JoeM didn't get your function name correct. Is it fGetVerNo?
If still not working, post the code from the function.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Well, it's actually called getClientID() and that is what I used in my code, just used getVerNo to avoid confusion. Here is the function:
Public Function getClientID() As Integer
On Error GoTo getClientIDError
Dim db As Database
Dim rs As Recordset
Dim lID As Date
Set db = OpenDatabase("c:\sts\STracking.accde")
Set rs = db.OpenRecordset("tblInfo")
With rs
.MoveLast
getClientID = .Fields("ID")
End With
rs.Close
db.Close
Exit Function
getClientIDError:
getClientID = 0
End Function
Oops. Typo on my part. That "f" should be there.Maybe JoeM didn't get your function name correct. Is it fGetVerNo?
To me, getVerNo means something entirely different than getClientID.
What makes you certain that the last record of unfiltered and unsorted recordset has the value you want? Is there only 1 record in the table?
To retrieve just a single value I would prefer a DLookup instead of opening recordset.
Another alternative is when database opens to set value of textbox on a form that never closes, such as a Main Menu. I do this. Then the value is always available for reference.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Dim intID as integer
IntID = GetClientID
Msgbox intid
ItsMe, setting to variable is not necessary. MsgBox calling function should work. Something else must be wrong.
Joe, have you step debugged?
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Interesting, never tried it.
I think you meant this question for the OP, not me, right?Joe, have you step debugged?
Yep, sorry picked up wrong name. So, BLFOSTER, have you step debugged? I can't see anything wrong with the code.
On second thought, a DMax() might be preferred domain aggregate function.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.