u could set a script by that button, that runs on a global field (Gfield) that u initialize with 0 or 1 ..., the script will be :
Set Field(Table::field; GlobalTable::GField) the field u wanna insert the serial number in
set Field (GlobalTable::GField; GlobalTable::GField + 1)
Yes you can do it by script
it is better to ist set a default value and it look nice
There can be a possible danger with this set field script. If two or more users perform this script at the same time, you can get identical numbers. Furthermore, in a networked database, your global field will revert to it's original value when you reopen the database the next time.
Here's a "bullet proof" method for generating serial numbers on demand when the database is such that two or more users might need to perform this script at the same time:
Define a second table, CardNumber, with just two fields:
MemberID (Number field)
CardNumber (Auto-entered Serial Number)
Relate them to your contact table like this:
Contacts::MemberID = CardNumber::MemberID
Enable "Allow Creation of Records via this relationship" for CardNumber.
Now this script step will generate a unique card number for each member when you click a button to perform a script. Should you accidentally click the button twice, no change in the number will take place:
Set Field [CardNumber::MemberID ; Contacts::MemberID ]
Just place the CardNumber::CardNumber field on your contacts layout and you'll see a serial number appear in it the first time you click the button to assign a card number to that contact record.
I followed (duplicated) your above method.
1) When I trigger the script button, it does not populate the "cardmember" table field.
2) Even with "allow Creations of Records" activated, that field is not populated either.
3) If I add a record in the cardnumber table, it will auto populate a cardmember number.
4) Your last line: Just place the cardnumber::cardnumber field on the contacts page (I don't understand, is the creating a field and how do you insert that cardnumber::cardnumber?).
Sorry I'm new to this game, but trying to learn "key functions" that can be of benefit.
Your several problems indicate that you haven't set up the needed relationships, fields and field options correctly, but I can't tell from your post what was not done correctly.
To add cardnumber::Cardnumber to your layout:
Enter layout mode
Drag and drop from the field tool to add a new field to your layout.
Select "Cardnumber" from the drop down list at the top of the specify fields dialog that this action opens.
Then click the Cardnumber field to select that field.
PS. I stumbled onto your post by accident. Due to a limitation in how this forum works threads more than 3 months old will not appear in recent items when you post a comment to them. This thread is several years old. When post to such older threads, I recommend starting a new thread and including a link to the original thread in it to improve the chances that someone will see your post.