Hawkins1989
New member
- Local time
- Today, 08:56
- Joined
- Jan 25, 2018
- Messages
- 10
Hi All,
I have a test database that I am using some for next looping to enter records to quickly make a lot of records for testing.
The table has only a few fields which is a date, disease (I work in a hospital hence this field) and new diagnosis which is a tick box.
I then have a second table with different diseases, from this I made a query that has a random number field and shows just a single result which is a randomized disease each time it is run.
I want to use this random result in vba with the loop and adding a new row in the recordset, this is where I am falling short I don't can't figure out how to link that query result to make it the value of the field. I tried holding it in a tempvar tried multiple types of DoCmd.OpenQuery and opening the query and typing the SQL but nothing seems to work.
This is what I have done so far, sorry for the pic, I wasn't sure what option to use to copy the code directly like other people do. I tried putting the DiseaseName recordset to set itself just inside the loop so it runs each time to get a different value, I would also like to randomize the new diagnosis tick box and the mod 5 seems to work but I imagine there is a better way to make it truly randomized.
Any suggestions would be very helpful.
Many thanks
Matt
I have a test database that I am using some for next looping to enter records to quickly make a lot of records for testing.
The table has only a few fields which is a date, disease (I work in a hospital hence this field) and new diagnosis which is a tick box.
I then have a second table with different diseases, from this I made a query that has a random number field and shows just a single result which is a randomized disease each time it is run.
I want to use this random result in vba with the loop and adding a new row in the recordset, this is where I am falling short I don't can't figure out how to link that query result to make it the value of the field. I tried holding it in a tempvar tried multiple types of DoCmd.OpenQuery and opening the query and typing the SQL but nothing seems to work.
This is what I have done so far, sorry for the pic, I wasn't sure what option to use to copy the code directly like other people do. I tried putting the DiseaseName recordset to set itself just inside the loop so it runs each time to get a different value, I would also like to randomize the new diagnosis tick box and the mod 5 seems to work but I imagine there is a better way to make it truly randomized.
Any suggestions would be very helpful.
Many thanks
Matt