I have a form that I use a combo box to navigate between records. My problem is that there are two records that it won't go to. I get the error message "You can't go to the specified record." My code is: - Private Sub MemberSearchCmb_AfterUpdate()
-
Form.FilterOn = False
-
DoCmd.GoToRecord , , acGoTo, MemberSearchCmb
-
Me.MemberSearchCmb = Null
-
End Sub
I've never had this happen to me before so I don't know where to start looking for the problem. I just don't understand how it could work for some records but not for others.
Okay, I did a bit of a cheat. I created a new combo box and let the wizard to the work for me. I then converted the macro to vba and copied the code back to my original combo box. Here is what I've got: - DoCmd.SearchForRecord , "", acFirst, "[MemberID] = " & Str(Nz(Screen.ActiveControl, 0))
Is this a good solution? I tested it and it does go to all the records correctly.
6 2561 NeoPa 32,556
Expert Mod 16PB - What type of data is in [MemberSearchCmb]?
- What values are available in this control?
- Which records can you not reach in this way?
- As an experienced poster why do we need to ask so many questions to determine what your question should have been?
MemberSearchCmb is bound to a number field but shows only a text field. The values that are currently in the database are 1, 2, 3, 4, 5, 6, 9, 11, and 12. Records 11 and 12 are the ones that I can't access.
In answer to question 4, I usually have a good idea of what information is needed to answer the my question. This one had me so stumped I had no idea what would be needed.
So data from some troubleshooting that I have done, when I debug the error and put my mouse over "MemberSearchCmb" in - DoCmd.GoToRecord, , acGoto, MemberSearchCmb
it says it equals 11 when I try to go to that record. Hope that helps.
NeoPa 32,556
Expert Mod 16PB
It becomes clear.
It seems you are trying to treat the value for the Offset parameter (for which you're using [ MemberSearchCmb]) as an index. Check out the Help section. It's not an index, but an offset. It's purely coincidental, and related to what you store as an index, that it worked for you before. If you have an AutoNumber index with numbers starting from 1 it will behave in a manner similar to selecting the index, but it never was. Hence the values that cannot be selected are the numbers which are higher than the count of records. Try selecting 9 and seeing which record it displays ;-) Seth:
In answer to question 4, I usually have a good idea of what information is needed to answer the my question. This one had me so stumped I had no idea what would be needed.
That makes sense. I make the point when I can, as so many members put so little effort into creating a question that makes sense and I want to emphasize how important an issue it is. I can appreciate it may not have been required on this occasion.
You are correct. When I go to what I think is record 9, it goes to the wrong record.
I changed my code to - DoCmd.GoToRecord , , acGoTo = MemberSearchCmb
and that doesn't do near what I want it to. I can't figure out a pattern of where it does go. It doesn't always go to the same record. It seems that every time I reopen the form, it changes which record comes up. Is there a better method of going to a record in the same form?
Okay, I did a bit of a cheat. I created a new combo box and let the wizard to the work for me. I then converted the macro to vba and copied the code back to my original combo box. Here is what I've got: - DoCmd.SearchForRecord , "", acFirst, "[MemberID] = " & Str(Nz(Screen.ActiveControl, 0))
Is this a good solution? I tested it and it does go to all the records correctly.
NeoPa 32,556
Expert Mod 16PB
Cheat more often. Access is there to do the work for you if you let it ;-)
Yes. That's an appropriate solution. I'm still guessing that this is your PK field, but it seems clear it is.
Another good cheat - Use Context-Sensitive Help more often. It's invaluable. I still use it a lot, but it's even more helpful for beginners.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: alloowishus |
last post by:
I have some records that will not delete, whenever I run a delete
statement in the Query analyzer, it never completes the statement, and
I am only deleting one record at a time. Can anyone tell me...
|
by: Julia Baresch |
last post by:
Hi everyone, I haven't found any reference to this problem on this
group or in Access 97 help. I hope someone here knows this - probably
a simple thing, but not obvious.
I designed a query to...
|
by: DaveDiego |
last post by:
I've had a user delete one of the client records, I do have a version of
the DB with all records intact before the deletion occured.
Whats the best approach to getting all the related records in...
|
by: Traci |
last post by:
My problem is in a form/subform. On the main form I have an unbound listbox
named OptionsInPlan. In the OnCurrent event of the main form I set the value of
the listbox with the code:...
|
by: MS |
last post by:
Access 97 here.
I want a simple way to "lock" certain records on a form. Some records remain
"live" until all data is available which happens over time. When all the
fields are complete, I want...
|
by: hharriel |
last post by:
Hi All,
I have created an update query related to high school course
information (name of course; credit hour; course description, etc.) I
am updating a master course information table. I am...
|
by: oduamy |
last post by:
Before I ask my question - I have to say THANKS for all of the wonderful information and help this forum has provided me!!! You are all invaluable. Also, I posted this on the Microsoft forum as well...
|
by: crassostrea |
last post by:
Hello and Happy New Year,
I have two tables in Access 2003 (Windows XP) with similar, but different, information. We’ll call them table A and table B. I want to count the number of records in...
|
by: sparks |
last post by:
I have always just got a count on records and put up a box at the top
of the entry forms saying something like 1 of 500 and updating it as
you got to 500 of 500.
I have never thought of this as...
|
by: bcogan6502 |
last post by:
I am using a form to display/edit some records from a table query. I can get the value I want to display, but I want to use a combo box that has a list loaded from another table to edit the field,...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |