To debug the issue, ask Access what is in the combo.
Open the Immediate Window (Ctrl+G), and enter things like:
? Forms!Form1.ATitle.Value
? Forms!Form1.ATitle.DefaultValue
? Forms!Form1.ATitle.ControlSource
Does this approach give you a useful lead?
Still struggling:
Private Sub Form_Open(Cancel As Integer)
Me.TNum.DefaultValue = 1
Me.ATitleCombo.DefaultValue = ""
Me.CTitleCombo.DefaultValue = ""
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Debug.Print "Value: " & Forms![My Table].ATitleCombo.Value & vbCrLf & _
"DefaultValue: " & Forms![My Table].ATitleCombo.DefaultValue & vbCrLf & _
"ControlSource: " & Forms![My Table].ATitleCombo.ControlSource
Debug.Print "Value: " & Forms![My Table].CTitleCombo.Value & vbCrLf & _
"DefaultValue: " & Forms![My Table].CTitleCombo.DefaultValue & vbCrLf & _
"ControlSource: " & Forms![My Table].CTitleCombo.ControlSource
Me.TNum.DefaultValue = Me.TNum + 1
If IsNull(ATitleCombo.Value) Then
Else
sArtTitle = Me.ATitleCombo.Value
sAlbTitle = Me.CTitleCombo.Value
End If
Me.ATitleCombo.DefaultValue = sATitle
Me.CTitleCombo.DefaultValue = sCTitle
Debug.Print "Value: " & Forms![My Table].ATitleCombo.Value & vbCrLf & _
"DefaultValue: " & Forms![My Table].ATitleCombo.DefaultValue & vbCrLf & _
"ControlSource: " & Forms![My Table].ATitleCombo.ControlSource
Debug.Print "Value: " & Forms![My Table].CTitleCombo.Value & vbCrLf & _
"DefaultValue: " & Forms![My Table].CTitleCombo.DefaultValue & vbCrLf & _
"ControlSource: " & Forms![My Table].CTitleCombo.ControlSource
End Sub
Produces:
Value: Test123
DefaultValue:
ControlSource: ATitle
Value: Test456
DefaultValue:
ControlSource: CTitle
Value: Test123
DefaultValue: Test123
ControlSource: ATitle
Value: Test456
DefaultValue: Test456
ControlSource: CTitle
In addition, when I look in the property sheet for the comboboxes text
matching "Test456" and "Test123" is there, and appears identical to values
selectable from the comboboxes.
For the two comboboxes:
RST: Table/Query
RS: SELECT [ATable].AName FROM [ATable];
RS: SELECT [CTable].CName FROM [CTable];
For the form
RecordSource: My Table
I have noticed though that the fields that are acting as the controlsource
for the two comboboxes are from My Table and not from the ATable or CTable
that are being used as lookup tables.
The two lookup tables have only one field each containing the vaules which
appear in the comboboxes. Each lookup table has a one-to-many
relationship.
TNum is 'sticking' & incrementing correctly, I get #name? still with both
combos. Any further thoughts ? Thanks for your patience and help. I
turned off the autocorrect as you suggested.
Ian