I've been working on a problem and want to try using the docmd.gotorecord to get to a certain record in a table. I've got that figured out but I don't know what to do once i'm on the record. I want to select a usernumber from that record. It should be fairly easy to but I can't figure it out. Any help would be appreciated.
Thanks
9 5362 NeoPa 32,554
Expert Mod 16PB CD Tom:
I want to select a usernumber from that record. It should be fairly easy to but I can't figure it out.
Do you mean you want to make the Control that's bound to the usernumber Field be selected as where the cursor is? If so, all the data selected or just the insert position added in there after the data?
I'll try and explain better. Here's the code I'm using. -
j = 2
-
strsql = "select * from scores order by RandNumber ""
-
Set rsscores = db.OpenRecordset(strsql)
-
Do While Not rsscores.EOF
-
DoCmd.GoToRecord acDataTable, "rsscores", acGoTo, j
-
SXFDA = rsscores("XFDANumber")
-
J = J + 2
-
rsscores.movenext
-
loop
-
there's other code but when I get to the docmd.goToRecord i get an error that rsscores isn't open
Use the recordset and FindNext: - strSQL = "select * from scores order by RandNumber"
-
Set rsscores = CurrentDb.OpenRecordset(strSQL)
-
If rsscores.RecordCount > 0 Then
-
J = 2
-
rsscores.MoveFirst
-
Do While Not rsscores.NoMatch
-
rsscores.FindNext "XFDANumber = " & SXFDA & ""
-
J = J + 2
-
Loop
-
End If
-
rsscores.Close
NeoPa 32,554
Expert Mod 16PB
Hi Tom.
Certainly there are Methods that you can (should) use when working with recordsets, which are quite different from what DoCmd and all it's Methods will give you. DoCmd typically works as an imitator of the human operator (In this case, takes you to a record on whatever (Form/Report/Datasheet) object is currently selected within the Access session.) whereas Methods of other objects help utilise those particular items. Generally it's preferable to use the latter where possible.
However, your question seems to imply (Correct me if I have this wrong.) that, for unstated reasons, you would actually like to use DoCmd specifically. If it's for manipulating a code recordset, IE. One that is not available to the operator directly - then you're out of luck I'm afraid. It only works as a way to work with items that are human-interfaceable.
I hope that makes sense.
NeoPa 32,554
Expert Mod 16PB
I have a rule of thumb that says use DoCmd when, and only when, there is no Method or Property that can work more directly with that which you're working with. It's a last-resort. It can be very helpful & important, especially where the interface doesn't provide a way to do it using the object model as defined. Otherwise though - I avoid it.
What i'm trying to do is get the XFDAnumber from the 2nd record in the file, I will then update that number into another file in record 1 then get the 4th record and put that into record 3 of the other file and so on.
Don't know if that makes sense or not.
NeoPa
I'm still working on the problem with the runners and not matching them up with the same person. I thought if I could put the runners number in a file and put the runners number they are match with that way I will have a place to look to see if that runner has ever been matched with that runner and if so select a different runner.
Does that sound like it might work???
NeoPa 32,554
Expert Mod 16PB CD Tom:
Don't know if that makes sense or not.
Very little. The natural lack of clear explanation is exacerbated by the use of many terms out of place. What strikes me as most important though (I can & do get past such shortcomings regularly.) is that there is no reference at all to the points I'd raised. You simply haven't dealt with them and that leaves me somewhere before first base.
NeoPa 32,554
Expert Mod 16PB CD Tom:
Does that sound like it might work???
I don't mean to sound snippy here but that may as well be in Mandarin (Not the orange). You ask a question about using DoCmd , and the next thing I know you're explaining something based on the internals of your particular database.
I do still want to help, but you need to communicate in such a way that someone reading has an idea of what you want.
As I mentioned before - when I post something in response it will always be hard for me to proceed unless you read and respond to that. Simply skipping over/past it is very confusing to someone in my position. Have you understood what I posted? Do I need to post the same again? If you really must jump around onto different subjects then a new thread would generally be required.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Eric |
last post by:
What's the best way to cancel the new record when doCmd.GoToRecord , ,
acNewRec is executed and before the new record is actually written to
the database.
I'm maintaining an existing Access 97...
|
by: STeve Lefevre |
last post by:
Hey folks --
I'm using the DoCmd.GoToRecord , , acNext to jump to the next record
after the user enters a value. The problem is, it throws an error if
it's already on the last record! What's the...
|
by: Timppa |
last post by:
Hi,
I'm converting ACCESS 2000 database to SQL Server. I have .adp
project.
In the .mdb I have form where I'll insert rows into two different
tables using docmd.GoToRecod ,,acNewRec.
In .adp...
|
by: Stack |
last post by:
Hello,
I have my data sorted on date desc in my form (multiple recs/table
style). When I want to insert a new record (with my self made button
and vba code(DoCmd.GoToRecord , , acNewRec)) the...
|
by: vostrixos |
last post by:
Hi all,i need some help
I'm working on a access project were i use a lot the docmd.gotorecord ,,next ..first ..last method and i use only once the DoCmd.GoToRecord , , acNewRec.Everything was...
|
by: vostrixos |
last post by:
Hi
I can't make a code work.What i do is that i'm creating a fileDialog object and later
in the same function i use a Docmd.GoToRecord.I've notice that after i use the '.show' property within the...
|
by: martintallett |
last post by:
Help!
I am trying to replace the Access Find button functionality on an old database.
I can make it work when I use a basic form with bound fields and a button which shows a popup form which...
|
by: aaronyoung |
last post by:
I have been using this forum to answer many questions regarding an Access database I am building (my first attempt at something like this - teaching myself as I go), and I've always been able to find...
|
by: Ben Lahoy |
last post by:
Hi!
My problem is basically in a search modal window, where the user is allowed
to make a selection on which option to take. After selecting an option and
then giving the data to search, the...
|
by: neosam |
last post by:
Hey all,
I am not able to integrate these 2 actions in one command. What i am doing is...
A button which sends a report with only specific data to a particular person (via outlook). I am able to...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |