Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is there an (event?) that creates a record? 2

Status
Not open for further replies.

simon551

IS-IT--Management
May 4, 2005
249
I'll try to explain my problem:

I have a subform in tabular view. On the form are some default values for fields. One field (not one that has a default) has been *required* in the table.

What happens for users is that they start to create a record and then realize they don't want that line so they delete the info in the fields.. This doesn't delete the record, however. And then they get a message that says "tblBlah.Blah is required" so they freak out and call me. I tell them to hit 'Esc' which works but they don't seem to remember this and it happens again.
I would like to avoid a lot of training about 'Esc' and the record selectors.

Anyway, I've thought I could just take the required property off and give a pop-up that says "Please enter a Blah".

This, if I knew where to put the test and msgbox, would solve the "required" problem: the reminder would replace the actual requirement. And then, maybe, I could put in another test that tests for certain aspects being present before actually writing the info to the database.

Thanks in advance for your help and I apologize for the round-about way I'm asking for assistance.
 
something like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.CurrentRecord.cboItems Is Null Then MsgBox "Please select an Item."

End Sub

but that doesn't work. invalid qualifier
 
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Trim(Me!cboItems & "") = "" Then
MsgBox "Please select an Item."
Cancel = True
End If
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
remarkable. thank you sir PHV. and thank you snyperx3 for pointing me in the right direction.

Now I've fixed the required property and replaced it with a test, resulting in a message. That's great.

But, I still will get that message if the user deleted all the fields.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Trim(Me!txtAmountUS & "") = 0 Then
If Trim(Me!txtAmountForeign & "") = 0 Then
If Trim(Me!cboItems & "") = "" Then

*Do Something to delete the record*

ElseIf Trim(Me!cboItems & "") = "" Then
MsgBox "Please select an Item."
Cancel = True
End If
End If
End If



End Sub
 
Will Trim(Me!txtAmountUS & "") = 0 ever be true?
Try Trim(Me!txtAmountUS & "") = "" and
Trim(Me!txtAmountForeign & "") = ""

I understand that they contain numeric values, but if you are trimming it, and adding "" then you need to compare it to "".

-Pete
 
Thanks for responding. I'm not really sure what the & "" is for. It's seems to work w/out it for the text boxes. Sometimes it will be 0 because that is the default value. This seems to be working but it is creating some (mostly) blank records because of the default values. There are other fields in the record. But I'm assuming that if they don't have anything in these three fields then they are not really attempting to create a record. Then I can clean up the blanks/0's later. I just want to stop them from getting an error message they don't understand while still prodding them to enter the relevant info. I understand this is probably sloppier than it needs to be and hopefully a better solution will occur to me down the road. At least this is working now:


If Not Trim(Me!txtAmountUS) = "" Or 0 Then
If Not Trim(Me!txtAmountForeign) = "" Or 0 Then
If Not Trim(Me!txtItemDate) = "" Then

If Trim(Me!cboItems & "") = "" Then
MsgBox "Please select an Item."
Cancel = True


Thanks again.
 
the & "" is in case the field contains Null...so you dont have to check for IsNull() along with = ""...



-Pete
 
You may try this:
If Not Val(Me!txtAmountUS & "") = 0 Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I'm getting closer. Thanks guys.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not Val(Me!txtAmountUS & "") = 0 Then
If Trim(Me!cboItems & "") = "" Then
MsgBox "You have entered an amount but not selected an item. Please select an Item."
Cancel = True
End If
Else
If Not Val(Me!txtAmountForeign & "") = 0 Then
If Trim(Me!cboItems & "") = "" Then
MsgBox "You have entered an amount but not selected an item. Please select an Item."
Cancel = True
End If
Else
If Not Trim(Me!ItemDate & "") = "" Then
If Trim(Me!cboItems & "") = "" Then
MsgBox "Please select an Item or delete the date. Or press 'Esc'(after hitting 'OK')."
Cancel = True
End If

End If
End If
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top