Hiding the default record

R

Raymond

Hi everyone..

Am having loads of trouble while adding records. You would have noticed that
when we add records, there is a pre-added blank record in the form itself.

I made a record maintaining sub-form which had the following items:-

Serial No.(auto no.)
Product ID
Product Description
Qty...etc....etc..

My requirement is to highlight the description to the user if it is blank by
any means(specifically..by a query output)... i used the conditional
formatting but the prblem is that the default record is also being
highlighted along with it.

Your help wud b gr8ly acknowledged...
 
S

strive4peace

Hi Raymond,

"there is a pre-added blank record in the form itself"

actually, the "new" record is not "saved" until you type and then move
to another record (or close the form)

to validate a record and prevent it from being saved, put code in the
form BeforeUpdate event

'----------------- make sure all required data is filled out

'make sure SomeControlName is filled out
If IsNull(me.SomeControlName) then

'if it is not filled out, then move the focus to that control
me.SomeControlName.setFocus

'give the user a message
msgbox "You must enter Some Data",,"Missing Data"

'if this is a combobox, drop the list for them
me.SomeControlName.dropDown

'don't save the record yet
Cancel = true

'quit checking and give them a chance to fill it out
exit sub
end if

'make sure the first Date is filled out
If IsNull(me.[Date1]) then
me.[Date1].setFocus
msgbox "You must enter the first Date",,"Missing Data"
Cancel = true
exit sub
end if

'make sure the second Date is filled out
If IsNull(me.[Date2]) then
me.[Date2].setFocus
msgbox "You must enter the second date",,"Missing Data"
Cancel = true
exit sub
end if

'make sure the second Date is >= Date1
If me.[Date2] < me.[Date1] then
me.[Date2].setFocus

msgbox "The second date, " & me.Date2 _
& " must be >= the first date, " _
& me.[Date1],,"Invalid Data"
Cancel = true

'IF you want to undo the entries to the record
'Me.Undo

'IF you want to undo the entries to the field
'Me.controlname.Undo
Cancel = true
exit sub
end if

'~~~~~~~~~~~~~~~~~~~~

read the Access Basics document in my siggy ...


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
R

Raymond

Thnx for this code, i'll try this.. but see I don't have to ask a user to
enter field there itself. That blank description is arising as a result of a
query I have already designed. I just want to, color the blank fields so that
when accessed later, the people can actually see that there is some blank
field left which needs to b filled..

strive4peace said:
Hi Raymond,

"there is a pre-added blank record in the form itself"

actually, the "new" record is not "saved" until you type and then move
to another record (or close the form)

to validate a record and prevent it from being saved, put code in the
form BeforeUpdate event

'----------------- make sure all required data is filled out

'make sure SomeControlName is filled out
If IsNull(me.SomeControlName) then

'if it is not filled out, then move the focus to that control
me.SomeControlName.setFocus

'give the user a message
msgbox "You must enter Some Data",,"Missing Data"

'if this is a combobox, drop the list for them
me.SomeControlName.dropDown

'don't save the record yet
Cancel = true

'quit checking and give them a chance to fill it out
exit sub
end if

'make sure the first Date is filled out
If IsNull(me.[Date1]) then
me.[Date1].setFocus
msgbox "You must enter the first Date",,"Missing Data"
Cancel = true
exit sub
end if

'make sure the second Date is filled out
If IsNull(me.[Date2]) then
me.[Date2].setFocus
msgbox "You must enter the second date",,"Missing Data"
Cancel = true
exit sub
end if

'make sure the second Date is >= Date1
If me.[Date2] < me.[Date1] then
me.[Date2].setFocus

msgbox "The second date, " & me.Date2 _
& " must be >= the first date, " _
& me.[Date1],,"Invalid Data"
Cancel = true

'IF you want to undo the entries to the record
'Me.Undo

'IF you want to undo the entries to the field
'Me.controlname.Undo
Cancel = true
exit sub
end if

'~~~~~~~~~~~~~~~~~~~~

read the Access Basics document in my siggy ...


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*



Hi everyone..

Am having loads of trouble while adding records. You would have noticed that
when we add records, there is a pre-added blank record in the form itself.

I made a record maintaining sub-form which had the following items:-

Serial No.(auto no.)
Product ID
Product Description
Qty...etc....etc..

My requirement is to highlight the description to the user if it is blank by
any means(specifically..by a query output)... i used the conditional
formatting but the prblem is that the default record is also being
highlighted along with it.

Your help wud b gr8ly acknowledged...
 
K

Ken Sheridan

You can prevent the control in the empty new record also being coloured by
testing for it being Null and the primary key control not being Null. Set up
the conditional formatting on the Product Description control like this:

Expression Is IsNull([Product Description]) And Not IsNull([Serial No])

Ken Sheridan
Stafford, England
 

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

Top