473,321 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Testing if an entered value exists

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 recordset.open with a select
query

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

Regards
PeterW

Nov 13 '05 #1
2 1964
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 www.mvps.org/accessweb). (Personally, I'd choose the latter
route.)

Nov 13 '05 #2
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")
rs.Close

Forms!FrmMov.CustNum.SetFocus
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.
PeterW
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andy Levy | last post by:
Hi Im trying to create a function that tests if a 'Username' exists in a particular table. If the value is found then the code generates 'Username1' as the username, and check if that username...
21
by: scandal | last post by:
I am a javascript newbie working on a script that checks whether a "path" from one element in an array to another is "blocked." Currently, the script pushes an already processed cell index (hence...
6
by: AAVF | last post by:
Hi We have a problem with a query. An Access database links via ODBC to a UNIX server. To speed things, we use the ODBC to load the relevant tables to the local PC that runs Access so that...
17
by: clintonG | last post by:
I'm using an .aspx tool I found at but as nice as the interface is I think I need to consider using others. Some can generate C# I understand. Your preferences please... <%= Clinton Gallagher ...
2
by: MS Newsgroups | last post by:
Hi, I am trying to build a function that returns a dataset.When populating the dataset, is it possible to test if a value already exists in a column and only add it if it is not already present...
7
by: sdanda | last post by:
I am working on windows applications(VB.net). I created a form with a textbox and one button. I would like to test the value entered in the textbox after this textbox loses the focus. The value...
2
by: laredotornado | last post by:
Hi, How do I write a query where if a column, "value," is NULL I return the phrase "No value entered" but otherwise return the column's value, even if it is the empty string? I'm tried to...
6
by: Strato | last post by:
Hi folks, I want to write some kind of test to check at startup if another instance of my script is already running. I don't want to handle writing of a PID file because it is too Unix/Linux...
482
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.