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

Default value isn't populating the table

Status
Not open for further replies.

lkennemur

Programmer
Aug 19, 2005
32
0
0
US
I have a combo box that has a default value and it is located on a subform. If I don't select a response from the combo box I want the default value to be entered in the table. Right now it's not recognizing it. I have also tried putting this code in the click event on the main form and it still doesn't work. Any ideas?

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.cboEnvironment) Then
Me.cboEnvironment = Me.cboEnvironment.DefaultValue
End If
End Sub
 
I tried that but when that happens the QstnID and OperatorID in tblOperatorResponses doesn't populate.

tblOperatorResponses
OperatorResponsesID
OperatorID
QstnID
Response

Any ideas?

Thanks
 
My subform has the property DataEntry = yes.

I don't know if that has anything to do with it or not.
 
How are ya lkennemur . . . . .

For a record to be saved it has to be in [blue]edit mode[/blue] (depicted by the pencil icon). [purple]Writing to the DefaultValue does not trigger edit mode.[/purple] So just [blue]write the value to the control instead (not the default property).
Code:
[blue]   Me!TextboxName = SomeValue[/blue]
Your code failed because it does have a value (is not null), the defaultvalue.

Calvin.gif
See Ya! . . . . . .
 
Which event should I put the code into?

Thanks!!!
 
Nevermind. I figured it out. Thanks sooo much for your help!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top