By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,316 Members | 2,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,316 IT Pros & Developers. It's quick & easy.

Testing if an entered value exists

P: n/a
I have a data entry form based on a query.

As a user enters data in the fields, I want to check if that data exists in
the underlying table.

I have tried Dlookup on the table and also a with a select

the error message I get trying to open the recordset is along the lines of

"The connection cannot be used to perform this operation.
It is either closed or invalid in this context"

I am sure this must be a common operation and I am probably making some
basic errors and omissions.

Any pointers on how I can resolve this would be very much appreciated


Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Awww, c'mon. You're basically asking someone to debug your code, but
you haven't provided any.

Sounds like you never opened your recordset. You could write a
function to do this or borrow stuff from Trevor Best (his site is
listed at (Personally, I'd choose the latter

Nov 13 '05 #2

P: n/a
Sorry about that, I thought it was such a basic mistake I was making that
needed little explaination.

A sample of the code is:

Set rs = db.OpenRecordset("TblCustomer")

rs.Index = "AccountNum"
rs.Seek "=", Forms!FrmMov.CustNum.Text
If rs.NoMatch Then
MsgBox ("The barcode scanned is not recognised as a Customer " & Chr(13) &
Chr(13) & _
"Scan any barcode to continue")

Forms!FrmMov.CustNum.Text = ""

Exit Sub

When I try to move the focus to the CustNum field I get an error message
saying I must save the field before executing the setfocus.

My problem is that I want to discard the faulty information scanned into the
CustNum field.

Many thanks.
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.