Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User types number in a box, then gets assigned that many records 2

Status
Not open for further replies.

firebirdta84

Technical User
Aug 23, 2007
56
0
0
US
I have a table named tblMaster with two fields - AssignedTo and CaseNumber. The CaseNumber is imported daily but the AssignedTo is left blank. I have a dozen users and they need the ability to "assign" CaseNumbers to themselves without going into the table. The main form, frmMain, has a textbox (txtNum) and a textbox pre-filled with their name (txtUser). I need to make it so the user can enter a number in txtNum, press a button, and then have that many CaseNumbers assigned to them by taking the value in txtUser and placing it in the AssignedTo field of tblMaster. The CaseNumbers should be assigned in the order they are in tblMaster (or the order of the AutoNumber field called ID)

Can someone point me in the right direction?

Thanks!
Joe
 
You cannot lock the table for assigning x number of records to a user, and have a second user wait until the first one grabs them. Unless assignment happens in a different mdb that can be opened exclusively. This reminds me of FAQ on generating Unique ID numbers in a Multi-User database.

You 'll have to find a way for saying that the table is available for assigning. Maybe a dummy file (existing or missing) could be a flag for that purpose.
Check if it exists
Delete it
Assign
Create ii back
If it doesnt exist wait and try again a little later.

For assigning use an updatable recordset based on this SQL statement
SELECT TOP " & txtNum.Value " FROM tblMaster WHERE AssignedTo IsNull;"
and loop until EOF updating the field AssignedTo
 
Code:
docmd.runsql "Update (Select top " & txtNum & " *
From tblMaster 
where txtUser is null) dt Set AssignedTo ='" & txtUser & "'"
 
sorry sb
Code:
docmd.runsql "Update (Select top " & txtNum & " * From tblMaster where AssignedTo is null order by id) dt Set AssignedTo ='" & txtUser & "'"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top