Notiophilus
Registered User.
- Local time
- Today, 10:02
- Joined
- Jan 18, 2015
- Messages
- 42
I have an option group which should display a value from a table if txtWords is null, but the result of a query if txtWords is not null. But though it shows the right results when I load the form, updating txtWords gives me all sorts of errors. Can someone help me work through this?
txtWords is in the main form, while the option group optLengthCat is in a subform (but inline).
Form_OnCurrent() event:
When I put this into txtWords_AfterUpdate() it starts throwing up errors. Specifically, when I delete a subform record using SQL I get 'record was already deleted by another user'; I think I might have fixed the problem with Me.Requery, but it feels really inefficient. :banghead:
Should I be using an unbound control? If yes, how do I make an unbound control that can edit or add new records?
txtWords is in the main form, while the option group optLengthCat is in a subform (but inline).
Form_OnCurrent() event:
Code:
'Enable or disable the option group
If Len(Me.txtWords.Value & vbNullString) = 0 Then
Me.fsubLengthCat.Form!optLengthCat.Enabled = True
Else
Me.fsubLengthCat.Form!optLengthCat.Enabled = False
End If
'Subform length option box
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
'Set myDB
Set db = CurrentDb()
'Check if Data Exists
Set qd = db.QueryDefs("qryLength")
Set rs = qd.OpenRecordset()
If rs.RecordCount <> 0 Then
If Not Len(Me.txtWords.Value & vbNullString) = 0 Then
Dim LLength As Long
LLength = DLookup("[LengthID]", "qryLength", "[StoryID] = " & Forms![frmStories].[StoryID])
Me.fsubLengthCat.Form!optLengthCat.Value = LLength
End If
End If
Set rs = Nothing
Set qd = Nothing
Set db = Nothing
Should I be using an unbound control? If yes, how do I make an unbound control that can edit or add new records?