Once more: MsgBox

  • Thread starter Thread starter an
  • Start date Start date
A

an

How is possible to personalize the MsgBox to the next
hypotesis:

A Form based in Table to add new records.

1 - If only one field without data, Then:
MsgBox "Field "x" without data. Do you like to
continue?"
If Yes: To continue to write data in field(s)
If No: Quit without save

(Never to save where one field it is without data)

2 - If all fields with data, Then:
Save this record in Table and continue on same Form.

Thanks in advance.
an
 
an said:
How is possible to personalize the MsgBox to the next
hypotesis:

A Form based in Table to add new records.

1 - If only one field without data, Then:
MsgBox "Field "x" without data. Do you like to
continue?"
If Yes: To continue to write data in field(s)
If No: Quit without save

(Never to save where one field it is without data)

2 - If all fields with data, Then:
Save this record in Table and continue on same Form.

Thanks in advance.
an

Have you make Search on Old post..??

A few post below......
"Closing form without changes"

Bye.
 
Thanks for your reply.

Yes, I do.

But, in this case, return error message:

"Statement invalid outside Type block."

an
 
After adaptations, I think lack the above line
.... (?)
to execute wich I need.


Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim strMsg As String

If IsNull(Me.FileName) Or _
IsNull(Me.Path) Or _
IsNull(Me.Ponto) Then

strMsg = msgbox("There are field without data. Do
you to continue?", vbYesNo)

If strMsg = vbNo Then
Me.Undo

If strMsg = vbYes Then
... (?)

End If
End If
End If
End Sub

Thanks in adavnce.
an
 
an said:
After adaptations, I think lack the above line
... (?)
to execute wich I need.

You don't need anything else, is not necessary check
VbYes, because the truble is on VbNO.

I think is not sufficient to Check Null value, because
if the user update a TextBox and after erase it this
control fail because the value is NullString<>Null.

So you must check Len(Me.FileName)=0 And IsNull(Me.FileName)
with all filed you need.....!

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim strMsg As String

If (IsNull(Me.FileName) AND Len(Me.Filename)=0) Or _
(IsNull(Me.Path) AND Len(Me.Path)=0) Or _
(IsNull(Me.Ponto) AND Len(Me.Ponto)=0) Then

strMsg = msgbox("There are field without data. Do
you to continue?", vbYesNo)

If strMsg = vbNo Then
Me.Undo
Cancel=True
End If
End If
End Sub

Thanks in adavnce.
an

Instead of two control to check Null and VbNullstring
i use this Function:

So :

If IsNothing(Me.FileName) Or IsNothing(Me.Path).......ecc...!!

Public Function IsNothing(varToTest As Variant) As Boolean
'*****************************************************************
'Name : IsNothing (Function)
'Purpose : Verifie if the Test Variable is Empty
'Called by :
'Calls :
'Inputs : Variant
'Output : Boolean
'*****************************************************************
IsNothing = True
Select Case VarType(varToTest)
Case vbEmpty
Exit Function
Case vbNull
Exit Function
Case vbBoolean
If varToTest Then IsNothing = False
Case vbByte, vbInteger, vbLong, vbSingle, vbDouble, vbCurrency
If varToTest <> 0 Then IsNothing = False
Case vbDate
IsNothing = False
Case vbString
If (Len(varToTest) <> 0 And varToTest <> " ") Then IsNothing =
False
End Select
End Function

Bye.
 
Back
Top