Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Next Problem - Validation of product type

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
pskeens
Asked:
pskeens
2 Solutions
 
fridomCommented:
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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
mansooralia_yahooCommented:
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
 
pskeensAuthor Commented:
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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now