alternative to GoToRecord not working properly.

smercer

Registered User.
Local time
Tomorrow, 08:59
Joined
Jun 14, 2004
Messages
442
Hi all

I am having problems with this code. I works only when the right record is the first record, however when the first record is not the record with the same ISBN number as the book that is scanned, it will give a error (see attachment)
Code:
Do While Me!sfrm_Current_Sales_For_Book_Des!ISBN_Number <> Me!With_ISBN_Number
            'DoCmd.GoToRecord , , acNext
            DoCmd.RunCommand acCmdRecordsGoToNext
        Loop

By the way, I have tried both of the lines in between the "Do while" and "Loop" by changing which line has the comment apostrophe

This is my resolution to my problem that I had when I wanted write code for GoToRecord line. this is also nested in a else If statement. would this have any effect to this?

here is the full if statement from the ELSE line

Code:
    Else
    If Not IsNull(Me![ISBN_Lookup].Value) Then

        'and now for the each record in the Each_Book Subform
        sfrm_Current_Sales_For_Book_Des!ISBN_Number.SetFocus
        'DoCmd.FindRecord S_ISBN, acEntire, False, , False, acCurrent, True
                
        Do While Me!sfrm_Current_Sales_For_Book_Des!ISBN_Number <> Me!With_ISBN_Number
            'DoCmd.GoToRecord , , acNext
            DoCmd.RunCommand acCmdRecordsGoToNext
        Loop
        Me!sfrm_Current_Sales_For_Book_Des!sfrm_Current_Sales_For_Each_Book_Datasheet_View.SetFocus
        DoCmd.GoToRecord , , acNewRec
       
        Me!sfrm_Current_Sales_For_Book_Des!sfrm_Current_Sales_For_Each_Book_Datasheet_View!Book_ID = Me!sfrm_Current_Sales_Book_Description!sfrm_Each_Book_Sales_Selected!Book_ID
        Me!sfrm_Current_Sales_For_Book_Des!sfrm_Current_Sales_For_Each_Book_Datasheet_View!ISBN_Number = Me!sfrm_Current_Sales_Book_Description!sfrm_Each_Book_Sales_Selected!ISBN_Number
        Me!sfrm_Current_Sales_For_Book_Des!sfrm_Current_Sales_For_Each_Book_Datasheet_View!Cover = Me!sfrm_Current_Sales_Book_Description!sfrm_Each_Book_Sales_Selected!Cover
        Me!sfrm_Current_Sales_For_Book_Des!sfrm_Current_Sales_For_Each_Book_Datasheet_View!Cost_Price = Me!sfrm_Current_Sales_Book_Description!sfrm_Each_Book_Sales_Selected!Cost_Price
        Me!sfrm_Current_Sales_For_Book_Des!sfrm_Current_Sales_For_Each_Book_Datasheet_View!Sale_Price = Me!sfrm_Current_Sales_Book_Description!sfrm_Each_Book_Sales_Selected!Sale_Price
        
    End If
End If


Thanks to all in advance
 

Attachments

  • error 2046.gif
    error 2046.gif
    5.8 KB · Views: 204
Last edited:
I have this awful feeling that I am about to display my ignorance but I have to ask, how do you come out of the Do Loop if you don't get a match?

Brian
 
I have a dlookup to check to see if there is a match first, if there is then it will enter a value in the "ISBN_Lookup" text field.

Sorry for leaving this out.

Thanks for helping :)
 
Finally worked it out. All it needed was a Me.refresh

I did not need a goto record because after the refresh it would appear in the appropriate spot on the subdatasheet.

Why did I not think of this one? I should have earlier.

Thanks again brian for helping :)
 
Did I? How? Not that I'm averse to praise! :o

It reminds me of a Sunday eve over decade ago , testing a new MVS system and my Senior Sys prog was having problems, I was the Tech Manager, he comes over to me and says " can I run something past you?"
" yes says I"
He starts to talk about TSO,
I say "whoa , start at the beginning how does" there followed dumb question number 1.
He shouts " that's it" and rushes off
Me " what is?"
Him " You wouldn't understand"
me :confused:

never be afraid to ask the dumb question :D

HTH
Brian :)
 
We all have a dumb question sooner or later :eek: . lol

Look on the bright side, you won't know if you don't ask ;)
 

Users who are viewing this thread

Back
Top Bottom