'Custom' message boxes (1 Viewer)

Status
Not open for further replies.

mattkorguk

Registered User.
Local time
Today, 23:07
Joined
Jun 26, 2007
Messages
301
Hi All,
I was after a way of building message boxes that could be updated while users are still in the database, here's what I came up with, hope it's of use to someone else;
Code:
Function aMessage(varMessage As String, aType As Integer, varTitle As String, Optional varGreeting As String)
On Error GoTo aMessageErr
Dim aUser As String
Dim body As String
Dim Title As String
Dim Greeting As String
   ' Purpose:   Create and display a more personal message.
   ' Argument:  Message to select from the lkDropDowns table.
'User
    aUser = DLookup("Option", "lkDropdowns", "[fieldname]='" & fOSUserName & "' AND [Tablename]='" & "Welcome" & "'")
'Body
    body = DLookup("Option", "lkDropDowns", "[Fieldname]='" & varMessage & "' AND [Tablename]='" & "Message" & "'")
'Title
    Title = DLookup("Option", "lkDropDowns", "[Fieldname]='" & varTitle & "' AND [Tablename]='" & "Title" & "'")
'Greeting
    Greeting = Nz(DLookup("Option", "lkDropDowns", "[Fieldname]='" & varGreeting & "' AND [Tablename]='" & "Greeting" & "'"), "")
    
    aMessage = MsgBox(Greeting & " " & aUser & ", " & body, aType, Title)
        
Exit Function
aMessageErr:
    If Err.Number = 94 Then
        MsgBox "Your login details have not been found!" & Chr(13) & Chr(10) & body, aType, Title
    Else
        MsgBox Err.Number & " / " & Err.Description
    End If
End Function

This can be called using; Call aMessage("2", 0, "1", "2")
All you need a simple lookup table (I've removed my login Id details);
lkDropDowns
Counter: TableName: FieldName: Option:
2 Message 1 this is message 1
3 Title 1 this is Title 1
4 Message 2 this is message 2
5 Greeting 1 Hi
6 Greeting 2 Oops

I'm sure others have had different ideas, but this suited my needs nicely. Makes the messages a little more personal and also provides the ability to update messages quickly without having to update the FE each time. :D
 
Last edited:

danit58

Registered User.
Local time
Today, 23:07
Joined
Aug 16, 2005
Messages
24
please,

can You add more exolain?

thank's in advance
 

mattkorguk

Registered User.
Local time
Today, 23:07
Joined
Jun 26, 2007
Messages
301
Sure.
Firstly create a new lookup table (lkdropdowns) as mentioned above.
This contains the following fieldnames;
Counter (autonumber field)
Tablename (Used to select section of message)
Fieldname (Used as reference for lookup)
Option (The details of the message)

Table with only 1 option available;
Counter: TableName: FieldName: Option:
1 "Message" 1 "You have just exported the report!"
2 "Title" 1 "Export Complete"

With this created, create a new module using the code above.

To use it, when someone exports a report;
Call aMessage("1", vbInformation + vbOKOnly, "1")

I hope that helps.
 

NauticalGent

CopyPaster of the First Order
Local time
Today, 18:07
Joined
Apr 27, 2015
Messages
3,079
Excellant idea and very useful utility!
 

isladogs

CID VIP
Local time
Today, 23:07
Joined
Jan 14, 2017
Messages
14,016
Posts #3 & #4 have just been discovered as part of an archeological dig(!) and very belatedly approved

In future, recommend reporting your own posts to moderated areas to ensure these are picked up promptly
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom