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

Subform default value not being writen to the table.

Status
Not open for further replies.

darkhat01

IS-IT--Management
Apr 13, 2006
144
US
I have a field in a sub-form that has the default value set to 99. But when I go to the record in the table it does not show up. However if I change the value to any other number the record is written to the table and shows up. Why is this? How can I get this sub-form to write this value to the table? The main form is in one table, and the sub-form is in another table.

Thanks,

Darkhat01
 
Are you adding any other data to the subform or is it just the linked field and the default value?
 
I am not adding any other data... The Idea is that 99 = Not Applicable. This does not apply to the program. 80% of the time 99 will apply, but to do reporting I need 99 to be writen to the report. Maybe this needs to be done in VB code. Any ideas?

Thanks,

Darhat01
 
The default value will not be written to the table until the record is created. This record is not being created, just 'suggested'. You will need to use some means of creating the record: an append query, an edit, etc.
 
If the record already exists when you open the form, the default value will not be applied.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
This is what I thought was going on... :(

So what would be the best process to make the record apply? Remou you said something about a append query or an edit; I am not familiar with this. I am going to do a google search but is there a recommended website you could point me to, to read about this information?

Maybe there is a better way to do this.

Thanks.
 
Ok so here is what I did do you see any problems with this??? It seams to work.... The one problem I have is if I go to the last record then click next to create a new record, then go back with out creating the new record it would make orphan records.

PROGRAM_LOCATON is in a subform.... maybe I should look at the main form and look if the ID is null...
Any feed back would be great.


If IsNull([PROGRAM_LOCATON]) Then
Me!CURRENT_LOCATON = 99
Else
'do nothing;
End If

Thanks,

darkhat01
 
Ok this worked for me.... Does anyone see a problem with this???

If IsNull([PROGRAM_LOCATON]) Then
If ([App_ID] <> 0) Then
Me!PROGRAM_LOCATON = 99
Else
'do nothing;
End If
Else
'do nothing;
End If
 
Why not simply this ?
If Me!App_ID <> 0 Then Me!PROGRAM_LOCATON = Nz(Me!PROGRAM_LOCATON, 99)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
how are ya darkhat01 . . .

Understand . . .
[ol][li]A form record can't be saved to an underlying table (via normal navigation) unless its in [blue]edit mode[/blue] (as depicted by the [purple]pencil icon[/purple] in the record selector)![/li]
[li]The Default Value or setting the Default Value [blue]doesn't trigger Edit Mode! (this is why a record with defaults set doesn't constant a record).[/blue][/li]
[li]To put a record in edit mode the user has to add/change some data in the record.[/li][/ol]
[blue]I hope this is clearer! . . .[/blue]


Calvin.gif
See Ya! . . . . . .
 
Are you sure you really need it to be saved in the child table?
A Left Join query would show up all parent records and all child matching records. An expression like Nz(ChildTableName!PROGRAM_LOCATION,"Not Applicable") would show what you need for parent records without any children, without storing unnecessary records to the table.
That's in case you may NOT have both 99 and other values...

[pipe]
Daniel Vlas
Systems Consultant

 
Thanks guys,

I do have a better idea of what is going on.

I am going to play around with what you said danvals.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top