Solved vbinformation

TipsyWolf

Member
Local time
Today, 03:08
Joined
Mar 20, 2024
Messages
245
hey guys ! so i have

Code:
Private Sub CmdMap2_Click()
   Dim strMessage
  strMessage = FormattedMsgBox(DLookup("nonEnglishText", "Tmsgbox", "msgID=7") & vbCrLf & vbCrLf & DLookup("nonEnglishText", "Tmsgbox", "msgID=8") & vbCrLf & DLookup("nonEnglishText", "Tmsgbox", "msgID=9") & vbCrLf & DLookup("nonEnglishText", "Tmsgbox", "msgID=10") & vbCrLf & vbCrLf & DLookup("nonEnglishText", "Tmsgbox", "msgID=11"), vbInformation, "Critical Data are Missed. ErrorID = 7-11")
 
  If IsNull(Me.RiskCode) Or Me.RiskCode = 26 Or (Me.locationID & "") = "" Then
    MsgBox strMessage, vbInformation, "Required Fields"
  Else
    Me.Dirty = False
    OpenMap
  End If
End Sub

and when i click OK, it pups up "required"
1726127530089.png

i dont need this information with "1"

but when i remove
Code:
MsgBox strMessage, vbInformation, "Required Fields"
it doesnt want to run map even if every data are entered.


could u please advise me how to run vbinformation only if there is no info in above stated conditions.. thank you.
 
I was going to say check the syntax, but it works for me?
1726129611225.png

From the IM window
Code:
strmessage = "Tipsywolf"
MsgBox strMessage, vbInformation, "Required Fields"
 
I was going to say check the syntax, but it works for me?
View attachment 116061
From the IM window
Code:
strmessage = "Tipsywolf"
MsgBox strMessage, vbInformation, "Required Fields"
but i dont need this window \ pup up.
let me describe it in another way.
i would like:

if l click on "map"
it checks if RiskCode =0 or RiskCode=26 or Me.locationID & "", then
msgbox "critical data are missed"

if riskcode has some value from 1 up to 25 (can't be any different number) and there is some location in me.location , then open a "map"

hope its clear. sorry.
 
so original stable which works fine is
Code:
Private Sub CmdMap_Click()
   Dim strMessage
  strMessage = "Ensure both a Risk Code and a Location are Entered."
  If IsNull(Me.RiskCode) Or Me.RiskCode = 26 Or (Me.locationID & "") = "" Then
    MsgBox strMessage, vbInformation, "Required Fields"
  Else
    Me.Dirty = False
    OpenMap
  End If
End Sub

but i when i add there FormattedMsgBox with dlookup it give me a 2nd pop up i dont need.
then i remove MsgBox strMessage, vbInformation, "Required Fields" so i doesn't give me info with 0 or 1 - it gives me en error
 
Last edited:
Sorry, I misunderstood the issue. I thought you were getting 1 in error from the MSGBOX function.
I do not have that other function, nor any inclination to use it at present.
I would inspect what is returned from that function and amend to suit.

If all it is is producing 1, then I would suggest you have it's syntax incorrect.
Instead of a stupidly long concatenation of code, break it down into small steps, so you can debug each and find your issue.
Then, and only then you can concatenate it back.
Personally I would just have as many striing variables as lines I need in that MSGBOX and then concatenate.

Edit: I would also ask why you are building that message, when you might not need to?
Edit:Edit: Just noticed that the stupidly long line of code already has vbInformation in it? :(

So in that case, you would need to remove those parameters as they are expected in the MSGBOX code, NOT in the message iteself?
 
Last edited:
I would think you'd want something like

if RiskCode < 1 or RiskCode >25 or isnull( Me.locationID) then
 
Sorry, I misunderstood the issue. I thought you were getting 1 in error from the MSGBOX function.
I do not have that other function, nor any inclination to use it at present.
I would inspect what is returned from that function and amend to suit.

If all it is is producing 1, then I would suggest you have it's syntax incorrect.
Instead of a stupidly long concatenation of code, break it down into small steps, so you can debug each and find your issue.
Then, and only then you can concatenate it back.
Personally I would just have as many striing variables as lines I need in that MSGBOX and then concatenate.

Edit: I would also ask why you are building that message, when you might not need to?
Edit:Edit: Just noticed that the stupidly long line of code already has vbInformation in it? :(

So in that case, you would need to remove those parameters as they are expected in the MSGBOX code, NOT in the message iteself?
so i spent another 1 or 2 hours and found out that @isladogs ' function gives error when i use " in text.


Code:
Public Function FormattedMsgBox(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
      Optional title As String = vbNullString, Optional HelpFile As Variant, Optional Context As Variant)       As VbMsgBoxResult

On Error GoTo Err_Handler

'Originally from http://www.trigeminal.com/usenet/usenet015.asp (now defunct)

       FormattedMsgBox = Eval("MsgBox(""" & Prompt & """, " & Buttons & ", """ & title & """)")

Exit_Handler:
   Exit Function

Err_Handler:
   MsgBox "Error " & Err.Number & " in FormattedMsgBox procedure : " & vbCrLf & "   - " & Err.Description
   Resume Exit_Handler

End Function

1st i thought i did mistake in syntax, then i played with length of txt and it later i found out i can't use quotation mark in this function and dlookup in it. just FYI.

thank you guys, u help me a lot !
 
Try using single quotation mark ' ? otherwise I expect standard protecting it would work? """
 
Try using single quotation mark ' ? otherwise I expect standard protecting it would work? """
i already just typed another word in vbinfo description to make it easer and avoid complex things.
i was using like "so called" to sound it more natural, but its totally okay now. :)
 
so i spent another 1 or 2 hours and found out that @isladogs ' function gives error when i use " in text.


Code:
Public Function FormattedMsgBox(Prompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
      Optional title As String = vbNullString, Optional HelpFile As Variant, Optional Context As Variant)       As VbMsgBoxResult

On Error GoTo Err_Handler

'Originally from http://www.trigeminal.com/usenet/usenet015.asp (now defunct)

       FormattedMsgBox = Eval("MsgBox(""" & Prompt & """, " & Buttons & ", """ & title & """)")

Exit_Handler:
   Exit Function

Err_Handler:
   MsgBox "Error " & Err.Number & " in FormattedMsgBox procedure : " & vbCrLf & "   - " & Err.Description
   Resume Exit_Handler

End Function

1st i thought i did mistake in syntax, then i played with length of txt and it later i found out i can't use quotation mark in this function and dlookup in it. just FYI.

thank you guys, u help me a lot !

That's not specific to 'my function'. It fails with a standard message box:

1726158151755.png


As the formatted message box is built on top of a standard MsgBox function , it also fails

As already mentioned, use single quotes (apostrophes) instead

1726158447173.png
 
That's not specific to 'my function'. It fails with a standard message box:

View attachment 116063

As the formatted message box is built on top of a standard MsgBox function , it also fails

As already mentioned, use single quotes (apostrophes) instead

View attachment 116064
wow, awesome :)
thank you very much !

btw , why do you use @ at the end of a sentence there ?
1726158583040.png

what it does specifically ?
 
Why not try it and see?
because I dont have @s and it does the same at the 1st glance. thats why i asked :)
i already put a few vbinfo and dlookup in it. and i just end sentence without @ and it looks the same.

i guess im wrong , but i dont see where exactly lol
 
Well I am just guessing here, but it might insert a VbCrlf , at least for the first one?
As there is one at the start of a new line in the display.
The one at the end *might* centralise the OK button, as in a MSGBOX I get mine on the far right?
 
The use of '@' is explained in the article.

When used with the Eval function, any text before the first '@' is in bold text with the remaining text on a new line as normal weight

Code:
FormattedMsgBox "Bold text here!@First line normal text.@Second line normal text.",vbOKOnly + vbExclamation, "Message Box Title"
 

Users who are viewing this thread

Back
Top Bottom