1) I want to auto update a field value by client ID. 2) Also want to update a value in a field in a table when someone creates new record in another - autonumber

Please be kind. I am retired and new to Access. I am helping a friend set up a simple(ish) database for their charity, and while I can manage the simpler stuff, I have run into a couple of problems.
I have a Client Master table- keyed on Client ID (autonumber). I also have a Client sessions table - keyed on Client ID and Session ID.
If I make the Session ID auto number then it increments regardless of the Client, but I want it to increment within each Client. How do I do that please?
Secondly - Each client can have multiple care packages, each consisting of 5 sessions. These need to be set up on the table Care Packages Master, where there is a field "Sessions used". When someone adds a record to the Sessions ID file using a form with subform that I have created I want the "Sessions used" field to be incremented by 1, and return an error if the 5 sessions have already been used.
Thanks for any help given to a beginner.

Related

Strange Behavior when saving customer with deletedatabaserecord=1

This issue brothers me for a long time.
I have two environments. 1 for development, 1 for production.
I did the same steps as below:
1, Create a new customer named "TESTID"
2, Delete the "TESTID" after creation immediately. At this time, it would be marked deleteddatabaserecord =1 in BAccount table.
Now, here comes huge different. If I recreated the "TESTID" in my development environment, the system allows and just update the deleteddatabaserecord to 0 and other fields updated according to new input. However, the production environment won't allow to created the customer "TESTID", says "Can not insert duplicated line into object "dbo.BAccount" with unique index. The duplicated key is (2,TESTID)"
This issue also happens to other entities, such as Stock Item. So is there a switch or specific setting?I would be really appreciated if somebody could give me the right direction.
The error says you can't insert entity into the table because of unique index constraint. And you don't have such error in another environment. I'd started investigating from checking if indexes are the same for dbo.BAccount table in either of the environments.

How can we know ID of the document on client side

I have recently learned tutorial about restful APIs.In that, my instructor suggested me that if we want to delete any document we should pass id in the parameter of the request. But now I am confused How do we handle this implementation on the client side.I mean how can even the programmer on the front side could be aware of that particular document ID. Does he need to go to the database each time?
Common practice for accessing a record in db is to use its unique identifier, to get or update or delete the record.
On the client side (if you mean user interface) when user wants to delete a document, he/she must see the document somewhere in the interface. Suppose a page with a table containing a list of all (for instance) books in the db. On each row, you have book title and author's name and the id of the book document in the db.
So you can use that id to call the delete rest API.
In a nutshell, when you want to delete something you must have got it from db to simply see it, so the id is at your hand.
When you want to delete a some doc from the database you need to get all documents to the front end to see what do we need to do to this data right ?
Imagine any database GUI that u have worked with..
let's say phpmyadmin when using mysqli
in that case you have php mydamin's GUI so that u can clearly see what are the tables and how things persist in the database. you need to see that in order for you to make decision
. Like that you will need to bring at least a portion of that data to the front end for user to see it and choose what portion of data the user want's to make changes or delete.
so when we have a set of data in the front end like a list, if a user select one item from that list the id or the name of that item can be send to the server side and make the task if the user wishes to do
that's why you need an Id or a identification field of that particular data..

Client VS Server Script?

Client Vs Server Script - for validating the following?
From the database, a list of countries in world (India,America,japan,USA etc.,) are queried and stored in a list.
Now, the user enters state name as text. This needs to be validated against the list of values.
Where should this validation be written? Client or Server?
You don't need a script for this case. You can have a Custom Record for the Countries and Custom Record for the States. State Custom Record will have a field for name of the State and another field that will source the the Country record which has a field for the name of the country. Once the custom records are created then you can now create the field from the record you want let say Contact record. Create a field Country which source to the Country custom record then another field for State which source to the State custom record and put a filter on based on the Country Field.
This way, when the user selects the Country the list on the State will only be populated with the state that has the same country from the state custom record.
This is something you can do on servers side so you avoid having problems with the user.
If the users is typing some whole wrong information, where'd you like to have the errors in a logfile on the client side where the user have to contact you first or would you like to have it server side so you'll see what's going on?
What matters aswell is the extensibility of your software, you can easy continue working on your code server sided otherwise you would need to update the validation ofc.
What's importat is that the Validation is cased locally (client) so you need to define the validation server sided but it will run locally.
You will try to use the input from the user, and do a list.Contains method or another validation method.
Hope you can work with this :)

Need recommendations for pattern for now.js object sharing in group

I have an application where I want to use node.js and now.js to share the state of an object within a nowjs "group" across any number of clients.
As an example of what I'm trying to do, let's say that within the multiroom chat example that comes with now.js, there could be any number of rooms, with the ID chosen by the user. If the user knows the ID, they can enter (or be the first to "create") that room. There is a "history" object that is maintained for each room once it is created and communication starts happening. The history object contains a property or two, and an array of comment objects, each with a user property, a comment property, and a datetime property. When a new user connects, they should immediately have access to the history.
Is there a way to store a group-scoped object variable on the server to sync with? Am I thinking about this in the wrong way? Am I crazy or a little slow?
OK...I got it.
I have a new function createHistory(groupid) on the server side, which returns a new history object if it doesn't already exist when the user enters the room(group). This would occur if this user just created the room.
This history object employs add, remove and list methods. Since I need to get at the list from the client, it's important that I use a callback like the following:
api.get = (callback) ->
callback(_history)
I assign the result:
everyone.getGroup(this.now.groupid).now.history = createHistory(this.now.groupid)
Now I can add history at the server:
api.add = (time,user,text) ->
_history.items.push {time:time, user:user,text:text}
And get to it from my client:
now.history.get (history) ->
for item in history
#do something...
The only drawback is once the room is empty, the history evaporates...I think. Although I suppose you could check for the last disconnect and persist it somewhere if you wanted.

How can I create human readable key for notes documents

For the documents stored in the database, I would like to create a human readable key to uniquely identify the document. e.g. PO20090110-001. How do I go about doing that?
When saving a document you can put together the first part of the number by using the date or any technique you like (ej. "PO" & format(date, "YYYYMMDD") & confDoc.getitemvalue("doccounter")).
As for the counter I like to store it in a configuration document and update it when each doc is saved. If there are lots of documents created during the day you can run into rep conflicts on you configuration document, if this is the case you can have an agent on the server do the actual assigning of the number, the drawback to this is that you don't get the number right away when saving.
Hope this helps.
One solution used in our help desk is to take the initials of the current user and add it to the a number in the last document in a view. Add one to the number and store that it the new document along with the ititals and the new number as the key.
It's not simply.
Create field for uniquely key and this key saving onSave (or other event), but you must protect this number to be unique.
You can create agent, which checking number on domino server and if agent find conflict then notify application administrator or other responsibility person to resolve this.
Or each replica generate own number and after replicate on domino, agent assign number in right format.
You can create a "nearly" unique key in Domino simply by using the #Unique function, with no arguments. This will generate a string key, based on the current user's first and last name and the current clock time. You will end up with a string something like: "ESCR-12345678".
I say "nearly" unique, because it is not really like an identity column in SQL - Domino does not guarantee it will only give out a particular string once. If you use #unique in a server-side agent which generates many id's at once - for example, and agent that loops and uses #unique within the loop, you can get into a situation where #unique will return a duplicate - because you create 2 docs within the same second and because your "username" is always the server's canonical name. But, outside of that scenario, #unique is generally safe to use.
If you then need to open or reference docs by this ID, just create a view sorted by that ID and you can a url in the form ../myView/id?readDocument.

Resources