FORM/SUB FORM - CODE NOT WORKING

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

Guest

Table tbl_PrspDemoInformation - Contains address, phone et
Table tbl_ProspectInformation - Contains academic information High School, GPA et

Form frm_PrspDemoInformatio
subfrm_PrspProspectInfromatio

Tab Control called Academic control name tab_Academic. Subfrm_ProspectInformation is sitting on top of this tab

If a user does not enter a high school name in the subfrm_ProspectInformation field name PrspInfoHSAttend control name PrspInfoHSAttend I want to populate this with a default of 6666666 which is also known as Unknown. This is a combo list box. List is coming from table tbl_HighSchoo

If that field is automatically populated I also want field name PrspInfoClassification which is also known as PrspInfoClassication with the default of FR also known as Freshman. This is also a combo box. List is coming from table tbl_Classification

By accomplishing the two steps above this will ensure that a record is always generated in table tbl_ProspectInformation once a user goes to a new record or save the record etc

I received the following from Albert Kallal. By the way thank you. This is simple and sweat and exactly what I'm looking for. Only problem is that it doesn't work. For some reason the Set ctl = Me!tab_Academic.Form!PrspInfoHSAttend appears in yellow and I have no idea what its looking for. So I can't even get to the second default in this case. This is exactly what I'm looking for though. Short and sweat. Wasn't looking for the not working part though. lo

Private Sub Form_AfterUpdate(
Set ctl = Me!tab_Academic.Form!PrspInfoHSAtten
If IsNull(ctl) = True The
ctl.Value = 666666
End I

End Su

Can someone please provide me guidance. What I would like to do is throw out the window the person that originally designed this thing but at this point I can only settle for a solution to this problem. I know it has to be a simple answer. I just don't understand why I can't find that answer

Next project is developing a audit trail database. That should be fun. Really would like to move on to it though was this problem is fixed. Please someone help.
 
if tab_Academic is a tab control, then it's not a subform control - so your
subform reference is incorrect. do the following:
1. open frm_PrspDemoInformation in design view.
2. if the Properties box is not open, right click on the subform and select
Properties. otherwise, left click once on the subform.
3. select the Other tab in the Properties box, and look at the Name
property.
4. write down the Name.

change the code as follows:

Private Sub Form_AfterUpdate()

Set ctl = Me!NameYouWroteDown.Form!PrspInfoHSAttend
If IsNull(ctl) = True Then
ctl.Value = 6666666
End If

End Sub

hth


John said:
Table tbl_PrspDemoInformation - Contains address, phone etc
Table tbl_ProspectInformation - Contains academic information High School, GPA etc

Form frm_PrspDemoInformation
subfrm_PrspProspectInfromation

Tab Control called Academic control name tab_Academic.
Subfrm_ProspectInformation is sitting on top of this tab.
If a user does not enter a high school name in the
subfrm_ProspectInformation field name PrspInfoHSAttend control name
PrspInfoHSAttend I want to populate this with a default of 6666666 which is
also known as Unknown. This is a combo list box. List is coming from table
tbl_HighSchool
If that field is automatically populated I also want field name
PrspInfoClassification which is also known as PrspInfoClassication with the
default of FR also known as Freshman. This is also a combo box. List is
coming from table tbl_Classification.
By accomplishing the two steps above this will ensure that a record is
always generated in table tbl_ProspectInformation once a user goes to a new
record or save the record etc.
I received the following from Albert Kallal. By the way thank you. This
is simple and sweat and exactly what I'm looking for. Only problem is that
it doesn't work. For some reason the Set ctl =
Me!tab_Academic.Form!PrspInfoHSAttend appears in yellow and I have no idea
what its looking for. So I can't even get to the second default in this
case. This is exactly what I'm looking for though. Short and sweat.
Wasn't looking for the not working part though. lol
Private Sub Form_AfterUpdate()
Set ctl = Me!tab_Academic.Form!PrspInfoHSAttend
If IsNull(ctl) = True Then
ctl.Value = 6666666
End If

End Sub

Can someone please provide me guidance. What I would like to do is throw
out the window the person that originally designed this thing but at this
point I can only settle for a solution to this problem. I know it has to be
a simple answer. I just don't understand why I can't find that answer.
Next project is developing a audit trail database. That should be fun.
Really would like to move on to it though was this problem is fixed. Please
someone help.
 
Thanks Tina. There appears to be a problem. I checked all the forms and non of them have a control property name. The first item in the other tab for each form is PopUp. If I go to the individual fields on the form the control names are there but not on the form itself.

Could this be the major headache I'm having. If so how come there is the control source name for these forms? Is that like the way it's suppose to be? Never noticed that until now

Thanks
 
Never mind that last message Tina. I found the names finally. The name of the sub form is subfrm_ProspectInformation and it's showing correctly

Question do you think the tabs are affecting this whole process. For example. First there's the main tab call tab_MainSheet then the tab Academic which subfrm_ProspectInformation sits on which is called tab_Academic

Do you think we need to reference these in the command so it knows where the find the subform location?
 
Well good news and bad news. I've revised the code and I don't get any error messages now. That's the good news. Here's the code

Private Sub Form_AfterUpdate(
Set ctl = Me!subfrm_ProspectInformation.Form!PrspInfoHSAtten
If IsNull(ctl) = True The
ctl.Value = 666666

End I

End Su

Bad news it doesn't fill in the default value of 7 6's.
 
Gee I think I'm talking to myself. lo

I think I found a solution to my problem but it has a flaw

I've inserted this command in the afterinsert on the main form

Private Sub Form_AfterInsert(
subfrm_ProspectInformation.Form!PrspInfoHSAttend = IsNotNul

End Su

Works great exactly what I need. The problem is if the user saves the record or tries to do anything a message pops up telling them that they need to fill in the PrspInfoHSAtten info. This is great but the message pops up a number of times before it will let you go the record and field

Any advise.
 
no, that's not a valid solution.
i think we're at the limit of verbal (written) explanations, here. if you
want to send me a copy of your database, i'll model a solution and send it
back to you so you can *see* how i did it - sometimes a picture really is
worth a thousand words.
if you want to do this, make a *copy* of your db and do the following to the
copy:
1. remove proprietary data, and add some "dummy" data so i have something to
work with.
2. *compact* the database
3. zip it to under 1 MB.
5. refer to the newsgroups in the subject line.
6. email to me at ttaccKILLALLSPAMess1 at yahoo dot com, removing all
the capital letters from the address.
i'll get back to you with a solution within a day or two.


John said:
Gee I think I'm talking to myself. lol

I think I found a solution to my problem but it has a flaw.

I've inserted this command in the afterinsert on the main form.

Private Sub Form_AfterInsert()
subfrm_ProspectInformation.Form!PrspInfoHSAttend = IsNotNull

End Sub

Works great exactly what I need. The problem is if the user saves the
record or tries to do anything a message pops up telling them that they need
to fill in the PrspInfoHSAtten info. This is great but the message pops up
a number of times before it will let you go the record and field.
 
Do you think we need to reference these in the command so it knows where the find the subform location?

PMFJI but... no; Tab Controls do not affect control or subform
references in any way. The reference is exactly the same whether the
subform is on a tab page or not.
 
Back
Top