By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 2,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

Urgent Help Needed - Migrated to access 2007 and now my db's are broke!?!

P: 56
Help! I just upgraded from 0ffice 2003 to Office 2007 and when I opened one of my DB's its broke!

Seems

<code>
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Carton#] = " & Str(Nz(Me![List2], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

</code>
is no longer allowed?

I keep getting this error:

Compile error:
Can't Find project or library


Can some one help me fix the code so when I type into the txt box it finds the record with matchin info?

I don't know what the "Str(Nz" part is from - one of you guys helped me set this up over a year ago.

Im in a rush - this is my eBay Tracking Database - and am in real bad shape without it.

Thanks!

Sophie
Apr 4 '08 #1
Share this Question
Share on Google+
4 Replies


Megalog
Expert 100+
P: 378
Try:

Expand|Select|Wrap|Line Numbers
  1. ' Find the record that matches the control.
  2. Dim rs As DAO.Recordset
  3.  
  4. Set rs = Me.RecordsetClone
  5. rs.FindFirst "[Carton#] = " & Str(Nz(Me![List2], 0))
  6.  
  7. if rs.NoMatch then
  8.       MsgBox "Record not Found"
  9. else
  10.      Me.Bookmark = rs.Bookmark
  11. end if
  12.  
  13. rs.Close
I'm not sure why you're using the Str function, that puts a leading space in front of the returned number. Might want to just switch it out with a Cstr instead, but that's just guessing based on what you've given here for code & table/field structures.
Apr 4 '08 #2

P: 56
Try:

Expand|Select|Wrap|Line Numbers
  1. ' Find the record that matches the control.
  2. Dim rs As DAO.Recordset
  3.  
  4. Set rs = Me.RecordsetClone
  5. rs.FindFirst "[Carton#] = " & Str(Nz(Me![List2], 0))
  6.  
  7. if rs.NoMatch then
  8.       MsgBox "Record not Found"
  9. else
  10.      Me.Bookmark = rs.Bookmark
  11. end if
  12.  
  13. rs.Close
I'm not sure why you're using the Str function, that puts a leading space in front of the returned number. Might want to just switch it out with a Cstr instead, but that's just guessing based on what you've given here for code & table/field structures.

I am not sure why there is a Str function either -

What I am doing is I have a form that opens that allows me to input data to a table based on the Carton# entered.

So when I open the form - there is a list box that is highlighted and waiting for entry or I can select from the list box - but I type faster than I scroll...so i would rather type it in. The list box "select" feature still works fine, but the typing part does not - for somereason it is not matching what i type to the list.

When I type a "Carton#" into the box - it pulls that record and allows me to edit the record.

There is no query behind this - just an open form w/input.

used to be a me. function and was pretty simple

I don't know where the str came from or the NZ either - I think that is something that the new access put in to try and fix the code when it opened it up.

Unfortunately I did not print the code before I upgraded - not realizing that the vba in access 2003 and access 2007 were not going to be seamlessly compatible.

Anyway if you have any idea how to do this your help would be greatly appreciated. I will try to get use the wizard and recreate the form...maybe I can get it to work that way.

Thanks!
Sophie
Apr 5 '08 #3

Expert Mod 2.5K+
P: 2,545
Hi. Have you checked under Tools, References from the VB editor that you still have a reference to the DAO object library? Looking at your code I am sure what you are using remains just as valid now as it was when it was written.

-Stewart
Apr 5 '08 #4

P: 15
I agree with Stewart, sounds like your references might be lost.
Open a module and go to tools, references and ensure your DAO and ADO libraries are checked off.
Apr 5 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.