G
Guest
I have some code that works well if there are already records in the table
components1. if the
count returns an empty record set, it gives an error. I need to have the
value
of 1 put into me.numentrytype.value if an empty record set is returned, if
not, the count of recoreds +1 needs to
go into Me.NumEntryType.Value ...
I've tried it in a number of ways, to no avail
the error is "run time error 2113"
The value you entered isn't valid for this field ...
debug shows it bombing out on Me.NumEntryType.Value = r("ct") because the
value is null ...
Private Sub Combo26_AfterUpdate()
Dim r As Recordset
Dim wksp As Workspace
Dim dbcur As Database
Dim sqstr As String
sqstr = "SELECT Count(Components1.EntryType)+1 AS ct "
sqstr = sqstr & "FROM Components1 "
sqstr = sqstr & "WHERE (((Components1.EntryType) = '" & Me.EntryType.Value &
"')) "
sqstr = sqstr & "GROUP BY Components1.EntryType "
sqstr = sqstr & "ORDER BY Components1.EntryType"
Set wksp = CreateWorkspace("", "admin", "", dbUseJet)
Set dbcur = CurrentDb
Set r = dbcur.OpenRecordset(sqstr, dbOpenDynaset, dbReadOnly)
Me.NumEntryType.Value = r("ct")
components1. if the
count returns an empty record set, it gives an error. I need to have the
value
of 1 put into me.numentrytype.value if an empty record set is returned, if
not, the count of recoreds +1 needs to
go into Me.NumEntryType.Value ...
I've tried it in a number of ways, to no avail
the error is "run time error 2113"
The value you entered isn't valid for this field ...
debug shows it bombing out on Me.NumEntryType.Value = r("ct") because the
value is null ...
Private Sub Combo26_AfterUpdate()
Dim r As Recordset
Dim wksp As Workspace
Dim dbcur As Database
Dim sqstr As String
sqstr = "SELECT Count(Components1.EntryType)+1 AS ct "
sqstr = sqstr & "FROM Components1 "
sqstr = sqstr & "WHERE (((Components1.EntryType) = '" & Me.EntryType.Value &
"')) "
sqstr = sqstr & "GROUP BY Components1.EntryType "
sqstr = sqstr & "ORDER BY Components1.EntryType"
Set wksp = CreateWorkspace("", "admin", "", dbUseJet)
Set dbcur = CurrentDb
Set r = dbcur.OpenRecordset(sqstr, dbOpenDynaset, dbReadOnly)
Me.NumEntryType.Value = r("ct")