Solved

Next Problem - Validation of product type

Posted on 2011-09-16
4
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

751 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