mattkorguk
Registered User.
- Local time
- Today, 23:11
- 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;
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.
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.

Last edited: