Please fix my code if possible:

R

Richard Horne

Hi guys,

I have designed a telephone call log database and have a tabbed menu system
with 10 pages each containg code on the on timer event to make them requery
every 1 minute, this works in the main but every now and then I get an error
message saying Field 'Tel ID' cannot be found.

Can anyone see anything wrong with the following code:

Private Sub Form_Timer()

Dim rst As DAO.Recordset
Dim lngID As Long
Dim CurCtl As String

If IsNull(Me.[Tel ID]) = True Then
Exit Sub

Else

CurCtl = Me.ActiveControl.Name
lngID = [Tel ID]

Me.Requery

Set rst = Me.RecordsetClone

rst.FindFirst "[Tel ID] = " & lngID

If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark

DoCmd.GoToControl CurCtl
Me.ActiveControl.SetFocus

End If

rst.Close

Set rst = Nothing

End If
End Sub

I have double checked all my sub forms and [Tel ID] is correctly named and
positioned on every form - this error message only seems to occur
intermittently and I'm not exactly sure what's causing it.

Can anyone help?

The system can sometimes go 2+ hours before the message appears but it does
keep coming back and it's very puzzling.
 
J

John Vinson

I have double checked all my sub forms and [Tel ID] is correctly named and
positioned on every form - this error message only seems to occur
intermittently and I'm not exactly sure what's causing it.

One possibility is that you may have the Table field and the Form
control both named [Tel ID]. I'd suggest renaming the textbox on the
form - Access can get confused. Try changing the name of the textbox
(and of course all references to it) to txtTelID.

It's probably not the source of the problem, but I'd also suggest not
using blanks in fieldnames.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top