473,404 Members | 2,178 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,404 software developers and data experts.

Very strange??

In a form the user can register new produkts. The code below prevent the
user to enter a numer already registered. The strange thing is that it is
still possible to enter no. 1 several times. On all other numers the code
seems to work. What is the reason/solution to this.!!

TIA

Sigurd

Dim lngArtikkelnr As Long
Dim conFilePath As String
conFilePath = strBackend
Dim dbs As Database, rst As DAO.recordset
Set dbs = OpenDatabase(conFilePath)

Set rst = dbs.OpenRecordset("tblProdukterFaktura", dbOpenTable)
rst.MoveFirst
rst.index = "PrimaryKey"
rst.Seek "=", lngArtikkelnr

If rst.NoMatch Then
'OK numer is free
Else
'code to let the user enter a new numer or use dmax+1
____________________________________________
KILLSPAM R e m o v e trippleX to reply
to email adress.
Nov 12 '05 #1
3 1129
I am not sure what exactly is happening with Seek, but I would in
general recommend another approach. Try using SQL and see how many
records are returned with your search criteria. If zero, your value is
unique. If not - it is already in the table.
I typically use an ADO recordset for this, with its RecordCount property.

Cheers,
Pavel

Sigurd Bruteig wrote:

In a form the user can register new produkts. The code below prevent the
user to enter a numer already registered. The strange thing is that it is
still possible to enter no. 1 several times. On all other numers the code
seems to work. What is the reason/solution to this.!!

TIA

Sigurd

Dim lngArtikkelnr As Long
Dim conFilePath As String
conFilePath = strBackend
Dim dbs As Database, rst As DAO.recordset
Set dbs = OpenDatabase(conFilePath)

Set rst = dbs.OpenRecordset("tblProdukterFaktura", dbOpenTable)
rst.MoveFirst
rst.index = "PrimaryKey"
rst.Seek "=", lngArtikkelnr

If rst.NoMatch Then
'OK numer is free
Else
'code to let the user enter a new numer or use dmax+1
____________________________________________
KILLSPAM R e m o v e trippleX to reply
to email adress.

Nov 12 '05 #2

"Pavel Romashkin" <pa*************@hotmail.com> skrev i melding
news:40***************@hotmail.com...
I am not sure what exactly is happening with Seek, but I would in
general recommend another approach. Try using SQL and see how many
records are returned with your search criteria. If zero, your value is
unique. If not - it is already in the table.
I typically use an ADO recordset for this, with its RecordCount property.

Cheers,
Pavel

Thank you for your answer. The seek method seeks for a similar record, and
works, but is for some reasons that I can't figure out, it will not find the
record if the numer is 1. As you propose I will try to use ADO,

Sigurd
Nov 12 '05 #3
Pavel Romashkin <pa*************@hotmail.com> wrote in message news:<40***************@hotmail.com>...
I am not sure what exactly is happening with Seek, but I would in
general recommend another approach. Try using SQL and see how many
records are returned with your search criteria. If zero, your value is
unique. If not - it is already in the table.
I typically use an ADO recordset for this, with its RecordCount property.

Cheers,
Pavel

Sigurd Bruteig wrote:

In a form the user can register new produkts. The code below prevent the
user to enter a numer already registered. The strange thing is that it is
still possible to enter no. 1 several times. On all other numers the code
seems to work. What is the reason/solution to this.!!

TIA

Sigurd

Dim lngArtikkelnr As Long
Dim conFilePath As String
conFilePath = strBackend
Dim dbs As Database, rst As DAO.recordset
Set dbs = OpenDatabase(conFilePath)

Set rst = dbs.OpenRecordset("tblProdukterFaktura", dbOpenTable)
rst.MoveFirst
rst.index = "PrimaryKey"
rst.Seek "=", lngArtikkelnr

If rst.NoMatch Then
'OK numer is free
Else
'code to let the user enter a new numer or use dmax+1
____________________________________________
KILLSPAM R e m o v e trippleX to reply
to email adress.

try using Dlookup.

Do While (DLookup("[PO_number]", "PO_Items_master", "[PO_number]=" _
& ordernumber))
ordernumber = ordernumber + 1
Loop
Nov 12 '05 #4

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

Similar topics

4
by: Google Mike | last post by:
I have RH9 and am using the PHP and MySQL that came with it. I was doing fine with all manner of my web pages for this app until I started having this very strange problem. It's a work order...
6
by: leonecla | last post by:
Hi everybody, I'm facing a very very strange problem with a very very simple C program... My goal should be to write to a binary file some numbers (integers), each one represented as a sequence...
2
by: TB | last post by:
I am seeing a very strange problem as follows... I have a loop where a fair amount of processing is going on and near the top of the loop I access a class that has only static helper functions...
5
by: cody | last post by:
I have a very funny/strange effect here. if I let the delegate do "return prop.GetGetMethod().Invoke(info.AudioHeader, null);" then I get wrong results, that is, a wrong method is called and I...
2
by: Shapper | last post by:
Hello, I have this code: Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}} Select Case Session("culture") Case "pt-PT" ... Dim cultureList(,) As String =...
12
by: John | last post by:
I can't get my head around this! I have the following code: <% .... Code for connection to the database ... .... Code for retrieving recordset ... If Not rs.EOF Then ... Do something...
2
by: peter | last post by:
Hi, I have very strange situation but first description ;) I have: 1) project in VB.NET, in this f.e. 1 function: Public Function Login(ByVal UserName As String, ByVal UserPassword As...
11
by: VijaKhara | last post by:
Hi all, I just write a very simple codes in C and vthere is a very strange bug which I cannot figure out why. The first loop is for v, and the second for k. There is no relationship between v...
4
by: Gotch | last post by:
Hi, I'm getting a very strange behaviour while running a project I've done.... Let's expose it: I've two projects. Both of them use a Form to do some Gui stuff. Other threads pack up messages...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.