Solved

Next Problem - Validation of product type

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 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