PC Review


Reply
Thread Tools Rate Thread

Can't seem to figure comparing records!!

 
 
Swagener
Guest
Posts: n/a
 
      28th Feb 2006
Hello fellows,

I,m stuck on this form and button for a while and have tried varies
methods but was unable to resolve the issue with my knowledge of vb in
access.

I have a form with a unbound text field (txtsearch) where staff enters
CustId (dmbarcode) and then click on a cmdbutton(check) which should
populate another form with the customer details which works fine if I
have a docmd.openform function but when I try to add some exception
handling into it, the error displays with "match not found for:
txtsearch" which I added in the code at the end against ELSE.
Testing:
Just to figure out what the dbopenrecordset is picking up from the
field dmbarcode in tbl_SO Cust Master, I changed the code in the ELSE
error from ScanBarcodeSearch to Dmbarcodecheck and turns out that it
picks out the first record only of the field in the table.

But I need to check the whole field to find a match and display the
details in the next form or display error with no match found.

Private Sub Check_Click()
Dim db As DAO.Database
Dim snp As DAO.Recordset
Dim Dmbarcodecheck As String
Dim ScanBarcodeSearch As String

ScanBarcodeSearch = Me.TXTSearch
Set db = CurrentDb
Set snp = db.OpenRecordset("SO Cust Master", dbOpenSnapshot)
Dmbarcodecheck = snp!DMBarcode
snp.Close
db.Close

ScanBarcodeSearch = Me.TXTSearch

If ScanBarcodeSearch = Dmbarcodecheck Then
MsgBox "Match Found For: " & ScanBarcodeSearch, , "Customer Found!"
DoCmd.OpenForm "search", acNormal, "", "[SO Cust Master].DMBarcode=" &
"'" & Me.TXTSearch & "'", acEdit, acNormal
DoCmd.Close acForm, "paratest"
'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & ScanBarcodeSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
TXTSearch.SetFocus
End If
End Sub

Thanks in Advance,
Please help me out here as I need to finish the apps by Friday.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to show the figure of the filtered records ? Kaman Microsoft Excel Misc 1 16th May 2008 02:34 PM
Getting duplicate records, can't figure out why! =?Utf-8?B?TGVv?= Microsoft Access Queries 3 9th Jun 2007 07:23 AM
Comparing fields and records and updating records cebAccess Microsoft Access Database Table Design 2 5th Oct 2006 02:59 PM
DCount - can't figure out how to set Criteria for certain records =?Utf-8?B?Um9hZEt5bmc=?= Microsoft Access Form Coding 3 26th Feb 2006 02:19 AM
Can't figure out how to get records needed Tony Girgenti Microsoft Access Reports 1 24th Mar 2004 03:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:45 AM.