On Mirosoft Access 2013 I have a form that requests the document number and revision from a user
i.e. "Enter Document Number", user enters Doc001
"Enter Revision Number", user enters 1
What I would like to do is add a "Create Record" button that when the user clicks it adds a new row to the "Documents" Table with a primary key that is a concatenation of Document Number and Revision.
So for the above for example the primary key on the new row would be "Doc001 Rev A"
Is this possible?
Thanks,
Don't.
Store DocumentNumber and RevisionNumber in the table as separate fields and have an Autonumber as the primary key. Bind the form to this table.
To display the concatenated number, use this expression:
[DocumentNumber] + " Rev " + Chr(64 + Nz([RevisionNumber], 1))
Related
I am using MS Access 2016 in an attempt to create a Form-driven database.
Suppose I have 2 forms - enter data into several Text Box's on Form One, then another form where user can keep updating/changing the record over time to update current status for only specific fields.
The problem I am facing is that data entered into Form One is placed in Record 1 on my Table, while data entered into Form Two is placed in the next Record (Record 2).
Question: How can I create a string of Forms, but have the data inputted into each of those Forms show up on the same Record in the same Table?
e.g. Form 1 has following fields
Name
Date
Style of Cause
Court File number
Status: "Open", "Close", "Re-Open"
Action Required
File Closure Summary
(and more 39 relevant fields)
Form 2 (I need to update the same record for only selected fields )
Status: "Open", "Close", Re-Open"
Current Status Summary
Status Summary
File Closure Date
File Closure summary
Action Required
Key Lessons Learned
For a class assignment I had to create a database and put 3 entries in. There were 8 fields to have information input, so to save time and not retype everything, I just hit the up arrow to modify the input, but I forgot to change the ID, so all 3 entries have the ID of 1.
My original code to for input into my table was.
Insert into People (id, FirstName, LastName, StreetAddr, City, State, Zip, Phone)
Values (1, "My firstname", "My lastname", "123 Main Street", "my City", "My State", "my Zip", "My phone number");
So, in my attempt to save time I messed up and put 1 as all 3 ID numbers, and now I don't know the correct way to edit a single part of an entry.
Here's a pop quiz that might get you to the point of fixing your problem for yourself...
What does your CREATE TABLE say?
Did the teacher talk about PRIMARY KEY?
Shouldn't id by AUTO_INCREMENT?
What value do you feed to id to get it to increment automatically?
What happens if you leave id and 1 out of the INSERT?
You can fix it by updating the values.
UPDATE People SET id = <put new id here> WHERE FirstName = '<FirstName goes here>' AND LastName = '<LastName goes here>';
This assumes that the FirstName and LastName values are unique enough to find only a single row. Replace the WHERE condition values to match the correct ones and choose a new value for the id.
Read the UPDATE documentation for more information about the syntax.
I got a text field for entering the new categories and submit with ajax ..
My script is working but everytime i submit new category mysql is creating one row to hold single category name .
I would like to create something like this eachtime when i add a new category the same single row should get updated
Id. User id. Category
1. 23. Personal , shopping , others +
So everytime i update a category name the row should be updated with the comma separated value . And also i would like to fetch the result in a select box
I'm trying to define a LOV with Universe Designer that when used in a #Prompt shows the user the item description, but gives back the corresponding item key as result of user selection.
e.g. From a dimension table of countries with two columns as COUNTRY_ISO and COUNTRY_NAME, I would like to show COUNTRY_NAME values to user with #prompt, but get back the corresponding COUNTRY_ISO as return value of #prompt.
This is possible using Index Awareness. I'll describe the solution using the sample "Island Resorts Marketing" universe, but the concept should map to your specific need.
For this example, we'll create a prompt on the "Country" object in the "Resort" class. The prompt will display the country names, but the condition will apply to the country_id field.
First, we need to identify the keys. On the Keys tab of the Resort\Country object, add a new Primary Key using Resort_Country.country_id as the source:
(in your case, you'll do this on the COUNTRY_NAME object, using COUNTRY_ISO as the primary key)
Next, we create the predefined condition that will include the prompt. Create a new Predefined Condition, named "Select country", with the following definition:
Resort_Country.country_id = #Prompt('Choose a country','A','Resort\Country',Mono,primary_key)
What we're doing is is applying the condition to the ID field (resort_country.country_id), but using the country name (the Country object) as the source. Note the "primary_key" parameter -- this tells BO to use the PK from the referenced object.
Now to test. Create a WebI report and select the "Select country" filter along with a field to display. I chose Service Line:
I run the report and am presented with a list of country names. I choose France, and I get a list of the Service Lines associated with France. The SQL generated by this query, reflecting my prompt selection, is:
SELECT
Service_Line.service_line
FROM
Service_Line,
Country Resort_Country,
Resort
WHERE
( Resort_Country.country_id=Resort.country_id )
AND ( Resort.resort_id=Service_Line.resort_id )
AND ( Resort_Country.country_id = 2 )
Note the very last line, which shows that the condition is applied using the ID, even though I selected the country name "France".
References:
- XI3.1 Designer Guide #Prompt info, starting on page 520
- Dave's blog on Index Awareness
- Dave's blog on Index Awareness with prompts
Long story but I'm dealing with a legacy ticket system where the 'id' field (pk/auto-increment) at one time was auto-incrementing by 1 but at some point the increment global variable was changed to 10. So I have a mess of tickets where the id for a lot of them is incremented by 1, but then starts incrementing by 10. I've been asked to cover this up.
I've created a new int field called "ticket_id" (not a pk and not auto-incrementing), and made some web-app changes to read the last ticket_id number, add 1 and then save that with a new ticket record. I've changed the web app to use the new 'ticket_id' field on the surface (while really still using the old 'id' field behind the scenes).
For the existing ticket records - is there an easy way to quickly add in an incrementing value to the new column (first ordering by the id field)? 1..2..3..
Try something like the following:
$result=mysql_query("select * from my_table");
$counter =1;
while($row = mysql_fetch_assoc($result)){
//suppose $row['id'] is your current primary key
mysql_query("update my_table set ticker_id=$counter where id=".$row['id']);
$counter++;
}