Solved

Next Problem - Validation of product type

Posted on 2011-09-16
4
282 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now