473,288 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

using the docmd.gotorecord command

489 256MB
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
Jan 23 '23 #1
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?
Jan 23 '23 #2
CD Tom
489 256MB
I'll try and explain better. Here's the code I'm using.
Expand|Select|Wrap|Line Numbers
  1.     j = 2
  2.  strsql = "select * from scores order by RandNumber ""
  3.     Set rsscores = db.OpenRecordset(strsql)
  4.     Do While Not rsscores.EOF
  5.             DoCmd.GoToRecord acDataTable, "rsscores", acGoTo, j
  6.             SXFDA = rsscores("XFDANumber")
  7. J = J + 2
  8. rsscores.movenext
  9. loop
  10.  
there's other code but when I get to the docmd.goToRecord i get an error that rsscores isn't open
Jan 24 '23 #3
cactusdata
214 Expert 128KB
Use the recordset and FindNext:

Expand|Select|Wrap|Line Numbers
  1. strSQL = "select * from scores order by RandNumber"
  2. Set rsscores = CurrentDb.OpenRecordset(strSQL)
  3. If rsscores.RecordCount > 0 Then
  4.    J = 2
  5.    rsscores.MoveFirst
  6.    Do While Not rsscores.NoMatch
  7.       rsscores.FindNext "XFDANumber = " & SXFDA & ""
  8.       J = J + 2
  9.    Loop
  10. End If
  11. rsscores.Close
Jan 25 '23 #4
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.
Jan 25 '23 #5
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.
Jan 25 '23 #6
CD Tom
489 256MB
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.
Jan 25 '23 #7
CD Tom
489 256MB
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???
Jan 25 '23 #8
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.
Jan 25 '23 #9
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.
Jan 25 '23 #10

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

Similar topics

3
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...
1
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...
0
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...
5
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...
1
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...
2
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...
3
martintallett
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...
2
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...
0
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...
5
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...
0
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"....
0
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
1
isladogs
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...
0
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...
0
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...
1
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)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.