Solved

Next Problem - Validation of product type

Posted on 2011-09-16
4
286 Views
Last Modified: 2012-05-12
On to the next issue.  As you can see by the code below I am trying to validate each detail to ensure the proper product is being billed out.  

- The first statement checks to ensure the TagID number is for a certain shipper.  This works
- Second statement ensures TagID is available for shipment, not already shipped.  This works
- Third and on does not work-  I am wanting to make sure for example; The TagID is the right Shape per the Load Line.  If not then message to user, if correct then next check.  It always tells me the Shape is not right regardless if it is or not.  I have specifically changed the shape in the table and still tells me its not right.  What is the best way to achieve this?  


        strSQL = "select * from DBO_TBL_INV_DETAILS where [INV_TAGID] = '" & TagID & "' and [INV_INB_SHIPID] = " & vIsID
        Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
       
           
                If rs.RecordCount = 0 Then
                    MsgBox "No Tag Available for Inbound Shipper ID - " & vIsIDName, vbOKOnly, "PULSE ERROR"
                    Me.Undo
                    BOL_TAG_NUM.SetFocus
                    Exit Sub
                ElseIf rs.Fields("INV_AVAIL") = "N" Then
                        MsgBox "Tag ID " & UCase(TagID) & " Is Not Available For Shipment", vbOKOnly, "PULSE ERROR"
                        Me.Undo
                        BOL_TAG_NUM.SetFocus
                        Exit Sub
                ElseIf Me.LD_DET_SHAPE <> rs.Fields("INV_SHAPE") Then
                        MsgBox "Shape Does not match load line", vbOKOnly, "PULSE ERROR"
                        BOL_TAG_NUM.SetFocus
                        Me.Undo
                        Exit Sub
                ElseIf Me.LD_DET_SIZE <> rs.Fields("INV_SIZE") Then
                        MsgBox "Size Does not match load line size", vbOKOnly, "PULSE ERROR"
                        Me.BOL_TAG_NUM.SetFocus
                        Me.Undo
                        Exit Sub
                ElseIf Me.LD_DET_GRADE <> rs.Fields("INV_GRADE") Then
                        MsgBox "Grade does not match load line grade", vbOKOnly, "PULSE ERROR"
                        Me.BOL_TAG_NUM.SetFocus
                        Me.Undo
                        Exit Sub
                End If
               
                rs.Close
                Set rs = Nothing
0
Comment
Question by:pskeens
4 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 36553138
Well it seems the posted code is from a Form. The form is not there. Well so far so bad. So my chrystal ball says you may want to use Me!LD_DET_SHAPE or
Me!LD_DET_SHAPE.Text it very depends on where this error handling takes place.

0
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 36553719
Your code should work to compate those two values.

What is the value of Me.LD_DET_SHAPE  and rst.Fields("INV_SHAPE")? Can you print those out? You can do so using Debug.Print:

Debug.Print "LD_DET_SHAPE: " & Me.LD_DET_SHAPE
Debug.Print "Inv_Shape: " & rst("Inv_Shape")

Note also that you don't need to reference the Fields collection of your recordset. You can simply use rst("Inv_Shape") to get the values from your recordset.
0
 
LVL 2

Accepted Solution

by:
mansooralia_yahoo earned 250 total points
ID: 36553784
Try trimming the objects trim(me.ld_det_shape) and trim(rst.fields("Inv_shapes"))

this should work if they are text/string types.
0
 
LVL 2

Author Closing Comment

by:pskeens
ID: 36553997
Trim function worked.  

Also thanks for the tip on not using "Fields" to get the recordset field.  Not sure why I always thought I had to use that.  I learn something new everyday!!

What a great community!!
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question