Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2007, 05:50 AM
Friend of Wrox
 
Join Date: Apr 2007
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old April 26th, 2007, 09:03 AM
Friend of Wrox
 
Join Date: Apr 2007
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:59 AM.


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