Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2007, 05:50 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default Find Criteria in Table

Hi All,

I am working on searching, checking PID field in table1 if match with table2 then start doing add or updation but somehow it not matching condition

Any help...

r.Open "Table1", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
t.Open "Table2", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do While Not r.EOF
    Criteria = "[PID]='" & r!f1 & "' "
    t.Find Criteria
            If t.EOF Then

                If Nz(r!f1, "") <> "" And Nz(r!f2, "") <> "" And Nz(r!f4, "") <> "" And r!f2 >= 1 Then
                    t.AddNew
                    t!PID = r!f1
                    t.Update
                  Else
                       ' Show Error
                End If
            Else
                If Nz(r!f1, "") <> "" And Nz(r!f2, "") <> "" And Nz(r!f4, "") <> "" And r!f2 >= 1 And Not t.EOF Then
                    t!PID = r!f1
                    t.Update
                Else
                  'error
                End If
            End If
    r.movenext
Loop

 
Old April 26th, 2007, 09:03 AM
Friend of Wrox
 
Join Date: Apr 2007
Posts: 110
Thanks: 1
Thanked 2 Times in 2 Posts
Send a message via MSN to ayazhoda
Default

Well i found answer

if any one eve has this problem try this but dont try this at home

Do While Not r.EOF

    If Not t.RecordCount <= 0 Then
        t.MoveFirst
    End If

Criteria = "[PID]='" & r!f1 & "'"
t.Find Criteria

            If t.EOF Then

                If Nz(r!f1, "") <> "" And Nz(r!f2, "") <> "" And Nz(r!f4, "") <> "" And r!f2 >= 1 Then

                    t.AddNew
                    t!SXID = r!f7
                    t!PID = r!f1
                    t!MinQuan = r!f2
                    t!Currency = r!f3
                    t!Price = r!f4
                    t!User = CUser()
                    t!SDate = Now()
                    t.Update

                Else

                    lblSPriceWarning.Caption = "Warning: Problem with importing Data, Please check Excel Sheet"

                End If

            End If

            If Nz(r!f1, "") <> "" And Nz(r!f2, "") <> "" And Nz(r!f4, "") <> "" And r!f2 >= 1 Then

                    t!SXID = r!f7
                    t!PID = r!f1
                    t!MinQuan = r!f2
                    t!Currency = r!f3
                    t!Price = r!f4
                    t!User = CUser()
                    t!SDate = Now()
                    t.Update

            Else

                lblSPriceWarning.Caption = "Warning: Problem with Updating Data, Please check Excel Sheet"

            End If

    r.movenext

Loop






Similar Threads
Thread Thread Starter Forum Replies Last Post
Find difference between table and updated table jasemhi Access 2 September 20th, 2008 04:25 PM
find all the controls inside any table amartya_mandal ASP.NET 1.0 and 1.1 Professional 10 October 24th, 2006 08:35 AM
Find replace in table crashes Pieter.de.boer Word VBA 3 September 18th, 2006 04:31 PM
How to find the last update time of a table dsekar_nat SQL Server 2000 4 July 27th, 2006 06:40 PM
find duplicate name on a table vickr1z Access 4 March 23rd, 2005 06:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.