make macro to set default value in table

smwabill

Registered User.
Local time
Today, 16:18
Joined
Feb 10, 2003
Messages
10
How do you make a macro in Access 2000 to set a default value in a table field

example:

Table field=worker

I want default value for worker to be 1 of 8 names

shft-F1 would set worker field to "John Smith"
shft F2 would set worker field to "Sally Smith"
etc..

Thank you--hope I haven't over or underexplained

smwabill
:)
 
Have you considered making a table that contains the list of names you have and adding them as a combobox to a form?

If you need to add more names, just add them to the table.
 
default value macro

Actually that is the way I have it right now--workers name with a combo box.

I am working in a query where I am doing a batch of receipts with the same name and do not want to select their name each time I put in a new record.

The workers name changes with each batch and sometimes the batches are like 60 to 90 receipts.

What I do now is go into the table before each batch and set the default value for the worker field.

Any suggestions?;)
 
If your working in a form, why not add an unbound text box to hold a default value that you can reference in your control for the worker name?
 
macro for default value

Thanks for your idea, but perhaps you overlooked my text that said I was working in a query.

But I will consider your idea if I can't program some macro keys to insert a default value while working in a query or datasheet

Thank you.

smwabill:)
 
If you set the Lookup property in your table design to open a combobox pointing at the table that contains the workers' names, it should carry through to queries (but not SQL stuff...)

i.e.:

tblWorkers:
autoWorkerKey (PK autonumber)
txtWorkerName (text)

tblReceipts:
autoReceiptKey (PK autonumber)
fkWorkerID (long int)

set the lookup property for fkWorkerID to combobox and the rowsource to tblWorkers. Adjust column settings to taste.

Then create a query that involves tblReceipts and includes the fkWorkerID field. When you open the query in datasheet view, you should see a drop-down icon.

--Looking-Up Mac
 
You can use a literal in your query since it is an append query, and the literal would be placed in the field.
 
Thank you all for your suggestions.

But trying not to be redundant, I will try to re-explain what it is I am trying to achieve, because--perhaps, I have not made myself clear enough.

I already have a table with a combo box lookup and if I key on the first few letters of the workers name it indeed comes up, but what I am trying to do is:

not to type at all in that field except for the first receipt-- I will show an example below.

Workers-Joe Smith, Tom Jones, Elizabeth Redding, etc.
Vendors----7-Eleven, Staples, Target, Macy's etc.
Category--Food, Clothing, Home supplies, Office supplies etc.

Now here is what I want it to do:
---------------------------------------------
---------------------------------------------
Pricefield: 3.95 (I enter the price and hit enter--no problem)
---------------------------------------------
Vendorfield: sta (I type a few letters, Staples comes up and hit enter--this already works--no problem)
---------------------------------------------
Categoryfield: off (I type a few letters, Office supplies comes up and hit enter--this already works--no problem)
_____________________________
Workerfield--Joe Smith (hit enter and click new record--this does not work--problem--If I go into the table before doing Joe's 90-some odd receipts and set the default value of workerfield to "Joe Smith" and go back into my query or datasheet it works fine because every time I click a new record, Joe Smith will come up automatically in workerfield without me having to do anything. I just don't want to keep closing down the query and open the table and inserting the value before every batch of receipts--When doing this amount of receipts you're trying to save keystrokes and opening and closing queries and tables, etc. Yes, I have programmed function keys to open and close tables, queries etc. in the autokeys section of macros, but it would be nice to set the table field default with the flick of a button. For example: I could set shift F1-F12 to each worker if I knew the manner or coding to change the default value.)

I hope I've made myself clear. I promise I won't spell it out again.
only answer questions if you have any.

Thanks for your continued patience.

smwabill

:) :)
 
Last edited:
I still don't understand why you don't do this in a form where you can hold the worker name as an unbound text box. You seem to be fixed on the idea of doing this in a table. There are limitations as to what you can do in a table and you've just hit one of those limits.

All of the combo box features that you have described will work just as well in a form.

Persitence is all very well, but you're beating your sword on a rock!
 
Okay, thanks--nobody told me that till you.

appreciate that.

smwabill.:)
 

Users who are viewing this thread

Back
Top Bottom