guys .... am already restructuring my codes as am doing a loop after it says that .eof = true if goes directly to endif ... not passing thru else, any idea why? - Set db = CurrentDb
-
Set rst = db.OpenRecordset("documentLog", dbOpenDynaset)
-
-
rst.MoveFirst
-
-
If Not rst.EOF Then
-
Do While Not rst.EOF
-
If rst!docLogNo = Me.txtDocLogNo.Value Then
-
Me.txtBadgeNo = rst!badgeNo
-
Me.txtFullName = rst!fullName
-
Me.txtWBRef = rst!wayBillRef
-
Me.txtLocation = rst!location
-
Me.txtFileCode = rst!fileCode
-
Me.txtDocType = rst!docNo
-
Me.txtDocNo = rst!docType
-
Me.txtDocTitle = rst!docTitle
-
Me.txtAssetNo = rst!assetNo
-
Me.txtEquipType = rst!equipType
-
Me.txtEquipModel = rst!equipModel
-
Me.txtAssetOwner = rst!assetOwner
-
Me.cmbTakeOutDay = rst!takeOutDay
-
Me.cmbTakeOutMonth = rst!takeOutMonth
-
Me.txtTakeOutYear = rst!takeOutYear
-
Me.cmbReturnedDay = rst!returnedDay
-
Me.cmbReturnedMonth = rst!returnedMonth
-
Me.txtReturnedYear = rst!returnedYear
-
-
Exit Do
-
End If
-
rst.MoveNext
-
Loop
-
Else
-
MsgBox "Record not Found!"
-
-
Me.txtDocLogNo.Value = ""
-
Me.txtBadgeNo.Value = ""
-
Me.txtFullName.Value = ""
-
Me.txtWBRef.Value = ""
-
Me.txtLocation.Value = ""
-
Me.txtFileCode.Value = ""
-
Me.txtDocType.Value = ""
-
Me.txtDocNo.Value = ""
-
Me.txtDocTitle.Value = ""
-
Me.txtAssetNo.Value = ""
-
Me.txtEquipType.Value = ""
-
Me.txtEquipModel.Value = ""
-
Me.txtAssetOwner.Value = ""
-
Me.cmbTakeOutDay.Value = ""
-
Me.cmbTakeOutMonth.Value = ""
-
Me.txtTakeOutYear.Value = ""
-
Me.cmbReturnedDay.Value = ""
-
Me.cmbReturnedMonth.Value = ""
-
Me.txtReturnedYear.Value = ""
-
-
Me.txtDocLogNo.SetFocus
-
End If
-
-
rst.Close
-
-
Set rst = Nothing
-
Set db = Nothing
12 2794
Hi
My initial thought here is that rst.EOF is actually False, but none ot the returned records match the txtDocLogNo value. This would then appear to do absolutly nothing !!
??
MTB
hi Mike, yes initially it's false ... my input in txtDocLogNo <> with rst!docLogNo so when .eof = true it must tell the user that record is not found.
I'm a little confused about your question. Can you explain the path you expect the code to take using line numbers from above? It sounds like you are expecting it to do the Do While loop starting on line 7 and then take the Else path on line 32 based on your title and question.
Also, are there multiple records where rst!docLogNo = Me.txtDocLogNo. Value? If not, there is a much better way to do this.
Hello master seth, to give a clear picture on this ... user will be searching onto me.txtDocLogNo, do while not rst.eof will go thru the records to find rst!docLogNo = me.txtDocLogNo( entry), the log number is not existing it must pass thru line 32 to tell that record not found .. I hope you understand my explanation =)
Once the test in line 6 is executed, it will either go to the True path or the False path (the Else). If it goes to the true path (there are records), then it won't go to the False side as the condition (Not rst.EOF) was already tested as true. So you need to reorder where you have your IF/Then statements to test for things as they will occur.
understood the explanation sir seth, I have tried re-organizing my if/then statements ... till now I can't figure out how to verify that record not found uuuuuuuuuufffff ...
A much better way to do this would be to setup a query that has the criteria equivalent to rst!docLogNo = Me.txtDocLogNo. Value. This is much more efficient that looping through every single record, which is what your code will do. If/when you get thousands of records, this will take a lot of time and the database can't benefit from any indexes. Try something like this (this assumes docLogNo is a number): - Dim db As DAO.Database
-
Dim strQuery As String
-
Dim rst As DAO.Recordset
-
-
Set db = CurrentDb
-
strQuery = "SELECT * FROM documentlog WHERE docLogNo = " & Me.txtDocLogNo
-
set rst = db.OpenRecordset(strQuery, dbOpenDynaset)
-
-
If rst.RecordCount > 0 Then
-
'Do your code here
-
Else
-
'Do your false code here
-
End If
-
-
rst.Close
-
-
Set rst = Nothing
-
Set db = Nothing
Now if only one record can match the criteria in the query, then you don't need a loop.
sir seth, yes docLogNo is number but I made it as docLogNo as text in table .... yes .. only 1 records can match the criteria ...
sir error --> DATA TYPE MISMATCH IN CRITERIA EXPRESSION in line - Set rst = db.OpenRecordset(strQuery, dbOpenDynaset)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: swaroophr |
last post by:
Which of switch statement and if-else statement takes less time to
execute?
|
by: paul |
last post by:
Hi all,
I've been handed some code and, unless I've got the numbering of
parentheses wrong, one of the functions has a curious if-else
statement. The thing compiles but is it right?
I know the code contains non-standard C++, but its only the if
statement I'm after. It seems to
go:
if (condition){
|
by: bitong |
last post by:
Just cant figure out how to formulate the correct syntax..I can do it in looping statement but my professor said that use only the simple if-else statement. The problem goes like this..Write a program that will determine if the number that you entered is either odd or even number..
I tried writing this code..
#include<stdio.h>
main()
{
int nos;
clrscr();
printf("Enter number:");
|
by: juan-manuel.behrendt |
last post by:
Hello together,
I wrote a script for the engineering software abaqus/CAE. It worked
well until I implemented a selection in order to variate the variable
"lGwU" through an if elif, else statement. I am going to post the
first 82 lines of the script, since the error message points at line
80:
from abaqusConstants import *
from abaqus import *
|
by: clear1140 |
last post by:
Good day!!
I was wondering if it is possible to put an if else statement inside a where clause of an sql statement... you see i would like my update statement to do this:
update trial_clear set num = @count2 /* @count2 is a integer passed*/
where
if (select top 1 def from trial_clear where num is NULL) is NULL
def is NULL
else
| |
by: MicaK |
last post by:
Good Morning,
I am new to this forum, and extremely new to VBA, so there may be a very simple explanation to this. I also apologize if I am giving you and excessive amount of detail. I have a table, tblAdmissions. One of the columns is for Certification and was set up as a lookup field that allows multiple values to be selected. In my form, the label for this field is called lblCertification, and the combo box is called cboCertification. ...
|
by: maveri4201 |
last post by:
I have written a php script (test3.php), which I attached as a text file. Its includes are also attached as text files. I'm trying to run the script here: http://www.wondergy.com/phptestbed/test3.php
The problem I'm having is the frustrating Unexpected $end. Yes, I know that it usually means something isn't being closed correctly. The problem is, I can't figure out what. To make the problem stranger, I can get it to parse when I break it up...
|
by: DanicaDear |
last post by:
I have this update strSQL that is working great, but I'd like to make it smarter in hopes of preventing input errors.
Here is my working code:
Else
Me.txtScan_Box_Num = Me.txtScanCapture
'Box exists.
'Assign box to current customer, and set box return date=now
Dim strSQL As String
strSQL = "UPDATE tblBOX SET...
|
by: Siddarth777 |
last post by:
here am sending u the code of the simple linked list implementation in C language
when we go to the append function definition,in the if statement a new node is being created if address of the structure is NULL
then after the creation the address is being assigned to the temp.
there is nothing weird in that
the weird part comes in else statement if you find a node
already created you goto the last node and then you append it by adding a...
|
by: Robert Ingles |
last post by:
I apologize for my current lack of knowledge and hope that someone will be kind enough to give me some additional help.I posted a question regarding "Record does not exist, open add record form". I have managed (with the help of ADezii) to have the add new user form open up if there is no matching userID record in the TBLUser (BTW Userid is text) however even if the user does exist the add new user form opens up. I think I need an "Else"...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |