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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validate record 1

Status
Not open for further replies.

shelron

Technical User
Apr 9, 2002
135
US
I have a form with a subform,

the user creates a new record on the main form,

How can I evaluate if they have made a selection from the subform so if they fail to make the subform selection, I can prevent the save, and prompt user to make the selection with a msgbox?

I just need a nudge in the right direction, what event, and logic.

thanks, ron
 
I would suggest having a seperate form for adding, and viewing/modifing records...

Then, on the form used to add disable the record selectors, and make it so the only way to save is to click on a save button you make.

Then the logic for this save button would be some thing like this.

if msgbox("save?", vbyesno) = vbyes then
if me!subformname!controlname = null then
msgbox "You need to select some thing from the bottom."
else
'code to goto new record, i can't remember it right now.
end if
end if

Hope all this gives you a direction...

--James junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Well you certainly gave me something to think about.

I would like to provide some more info, and subsequent logic.

The main form collects information about people, (address book), the subform collects info about the people - their relationship to projects, and their status,

so I have tblAddressBook (one) to tblContacts (many)


tblAddressbook is the main form, and tblContacts is the sub.

The main form allows users to search for people based upon their name, title, etc. It is laid out so if a user cannot find a person, they can click a command button to add a new person on the main form. They are also SUPPOSED to add a corresponding record in the subform by selecting from a combo box. The rub is that if they do not select something from the subform, a record is not created in the tblContacts table. (so I don't know how to evaluate a null condition if no record is present)

Further, I am using the default behaivior of save, meaning when the user exits the form or the application the record is saved. (this may be bad design, I never really considered it before now)


Based upon my current design, the only thing I can think of that would work would be the following,

disable auto save (don't know how to do that), then run code on the new record that creates a corresponding record in the tblContacts table, then evaluate for a null condition when the click the save button.

Does this make sense? Or am I off in lala land?

thanks, Ron
 
Yea, it makes some sence... I have a question or two here...

When the user clicks on a command button to add a new record, does it bring up a form all it's own to add them, or what does it do??

If it does bring up a form that is just for adding a record, I can help you force it to require that field...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
No the cmdbutton just starts a new record.

ron
 
ok, I would suggest as i said above...

Make a new form, and use that for only adding new records...

Then, ok that put a save button on it... and disable any way for them to close the form... and some code like this in the on exit.

if me.dirty = true then
msgbox "The current addition will be discarded."
me.undo
end if

you will have to make a save button that checks every thing and then if it's all good. You can save it and close the form...

i would suggest also putting in a command to refreash/requery the calling form on close the the addition form...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
THanks for your help, sounds like a good solution,

ron
 
Ok, Let me know if you need help with it...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top