Do not close if field is not filled

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using Access 2000 and would like to know if someone could please correct
the following. I have two fields: KeyWord (a text field) and Merge (a
checkbox). For any record where Merge is checked, I would like to have be
reminded to enter a Key Word if I have left it blank.

Any help would be greatly appreciated. Thanks!

====
'If any record has a check mark for Merge and does not have an entry for
KeyWord display message box reminder
'If all records have an entry for KeyWord when Merge is checked then close
form
If (IsNull(KeyWord) = True) And (IsNull(Merge) = False) Then
MsgBox "Please Enter a Key Word"
MergeWord.SetFocus
Else
DoCmd.Close
End If
 
A previous post by John Vinson in one of the Access Groups gave me the
answer. (I have changed the fields)

'John Vinson from access.chat
If Me!KeyWord= True Then
If IsNull(Me!KeyWord) Then
MsgBox "Please Enter a KeyWord", vbOKOnly
Cancel = True
Me!KeyWord.SetFocus
End If
End If
 
I am hoping that John or someone else can help on this:
John's code checks the current record two see if there is a check in one
field to make sure that there is an entry in the other. Is it possible to
check all records. That is if there is a check in any of the previous records
to make sure that there is an entry in Keyword?

Thanks again for your help.
 
You could do that at a basic level just with a query.... list of where
there's a check, but no keyword. What you do with that.... just display a
warning.... limit the form to only display those records.... send a rude
email to the person responsible.... is another question entirely.

If you need help with that then I'd suggest posting a new message.
(...though if you're going for the rude mail then I'd suggest the phrase
'monumentously cretinous')
 
Rob:

Thanks for your help. I think what you are saying is do a select query where
the field Merge is checked and where there is no Keyword.

How do I display a (polite!) message if the result includes at least one
record?

Thanks for your help.
 
You can just do something like...

dim n as integer
n=dcount("[chkField]","CheckingQuery")
if n=1
msgbox "You appear to have some dodgy data"
docmd.openreport "ReportBasedOnCheckingQuery"
elseif n>1 then
Call SetTheAttackDogsOnUser()
else
Call SendUserANiceBunchOfFlowers()
end if
 
You can just do something like...

dim n as integer
n=dcount("[chkField]","CheckingQuery")
if n=1
msgbox "You appear to have some dodgy data"
docmd.openreport "ReportBasedOnCheckingQuery"
elseif n>1 then
Call SetTheAttackDogsOnUser()
else
Call SendUserANiceBunchOfFlowers()
end if

<LOLSTC>

Rob, Rob - you KNOW you shouldn't post functions like that without the
source code!

Thanks... I needed a laugh today!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Rob and John:

Thank you very much for your generous help. It is really exciting to get
this form working as it should.

John Vinson said:
You can just do something like...

dim n as integer
n=dcount("[chkField]","CheckingQuery")
if n=1
msgbox "You appear to have some dodgy data"
docmd.openreport "ReportBasedOnCheckingQuery"
elseif n>1 then
Call SetTheAttackDogsOnUser()
else
Call SendUserANiceBunchOfFlowers()
end if

<LOLSTC>

Rob, Rob - you KNOW you shouldn't post functions like that without the
source code!

Thanks... I needed a laugh today!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top