Update tables depending on parameter value MySQL - mysql

I'm having a bad day and can't think of an answer to this...
On my form I have a number of inputs, I'm updating some of them back to the database when the Save button is pressed. My issue I'm thinking is.
How can I match the Input field which I have stored as a parameter and check to see if this differs from what is already input or if the field is null then update with the parameter value, and another parameter value is x for example how can I update another table?
As an example my form has name, telephone, rented/owned, house type & notes. When I click the Save button these values will be pushed into a Procedure using IN parameters. I've updated fields in the table with the values which is great but, is there a way to check that the parameter value is different than what is in the table already and update this. As I don't want to update all the fields if they don't need to be. Also say rented/owned parameter was rented then is there a way to update a different table.
How is it possible to write in the procedure if parameter x = rented update table A else update table B?

Related

Updating one table in MS Access with data from another

In MS Access 2016 I have a table named Master that periodically needs to gets updated with ‘updated’ data from a table named NewData. Each table has the same fields, except Master has one additional field named OTHER_SOURCES (explained further down). They each have an indexed unique id field named EVENT_ID. I’ve built an update query where the tables are joined one-to-one on the EVENT_ID field. In this query I have the fields in Master getting updated to the new values from the same fields in NewData if the TIMESTAMP field value is different. If the TIMESTAMP values haven’t changed, then those records do not get updated. This part is pretty straightforward and works fine.
However, I have end users that may make occasional changes to the values in the SIZE field of Master that need to be preserved and not overwritten with updated values from NEW_DATA. When a user makes a change in SIZE field, he documents the change with information obtained from other sources, which is stored in the extra field I mentioned earlier: OTHER_SOURCES. Here’s what I need to do, and I just can’t figure it out. Whenever a user has made a change to the SIZE field for a record, I need the update query to not override that value in the SIZE field, but still update the values in all the other fields (again, assuming the TIMESTAMP values are different between the two tables). It seems I need to use an IIF statement, but I’m thinking it needs to be done in VBA where I’m a bit of a hack. See screenshots. I greatly appreciate any help you can offer.
enter image description here
enter image description here
You can still proceed with the update, but update it to the same value as its previous value:
SET SIZE= IIF(nz(OTHER_SOURCES,'')<>'', MASTER.Size, NEW_DATA.Size)
This assumes that anything present in the MASTER.OTHER_SOURCES column indicates that the user has changed MASTER.Size. Note that MASTER.Size will never be updated from NEW_DATA.Size until someone (end user) removes MASTER.OTHER_SOURCES.

SQL Rowsource not working anymore after loading in values from another table

I have created a form whose comboboxes get "DISTINCT"-populated with values (from a table), which means nothing is selected at first, but the combobox offers a load of values to select from named table. In Field 1 I select a value and then Field 2 automatically loads in only values from the table where the criteria fits the value from the first field and so on. This way, I am narrowing down the numbers of applying recordsets from my table down to 1 or 2 just by clicking and choosing options. My Form looks this way.
I have a total of 16 rows where in each row I can narrow down parameters to 1 specific item from the table.
With pressing a button, I can write these values into another table where they will get a save ID and a save name. This all works flawlessly.
I also added a loading button, where I can select the savenames from the savetable and the form will automatically get filled with the values from the savetable. But as soon as I do this, no values are suggested anymore in the field that contains multiple Columns. I tried a Requery, I tried reassigning the Rowsource, I tried just deleting the values in the fields before, nothing helps. I have to use my "erase" function where I set all fields to "Null" to be able to get the "suggesting values" back to work.This is how it looks after loading
In the regarding field should be at least 3 values which get not displayed anymore.
It feels like filling the forms' fields with comboboxname.value = rs!valuefromsavetable deletes or blocks the rowsources from working.
Can someone help me here?

MS Access-Using value from a form in a calculated field of a table

I have a text box in a form which accepts a date.
I have to use that date in the calculated expression in a field of a table.
Initially I have tried to use this statement in the calculated expression.
[Forms]![Input data form]![Text38]
But it shows that "The expression cannot be used because refers to another table".
How to access the value of the text box?
I think I understand your question. You have a table and you want to use a calculated field in it that references a value in a form.
You will not be able to do it that way. The reason you are getting an error is because the form data only exists when the form is running. If you used that expression in the record source query of the form, you would be ok.
You have a couple of choices depending on what you are trying to do with the data. If you REALLY NEED a calculated field in your table, you can use a form to make an UPDATE to another field in your table; then it is static data and your calculated control can work.
Another option is to have a separate table to store the user input value, then use a VIEW (QUERY in Access terminology) to join the data together and compute the result. Depending on why you are doing it, this is typically the method you want to go with.
If this does not answer your question and you have something more specific, I will try to tailor the answer more.

How can i run the report without specifying the parameter value in SSRS

H, I have a parameter 'Client' as drop down in SSRS report. My requirement is to select all the records for all the clients if i don't select any parameter value and if i select particular value in the drop down,i need to display records for the that particular client.
I am getting the list of clients as a input from query.How can i add option select all by default.
Thanks in advance
You can do this a few ways...
Check the "Allow Multiple values" on the general tab of the Parameter Properties, go into the Available values and select the dataset you are using to get the values, make sure the the column that contains the actual data to search on is what you select for the VALUE field...(with this one - make sure your query eliminates the NULLs for the Value field) then you will have a drop down with all the values and it will add Select All...
Then in the Default Values tab, you can hook to the same query and select the VALUE field again... (as long as there aren't any NULLS) You may need to do tweaking depending on your query and values...
or
You can check the "Allow Null Value" on the General tab in the Parameter Properties, then in the Default Values - select "Specify Values", then Add, and (null) pops in there automatically...
Then call a stored procedure where the parameter defaults to NULL and if you pass NULL or don't pass in a string of values, your query will return all (not sure how you'd implement this if your query is embedded in the report... I try to do all of mine in Stored Procedures..)
Add "All" to the results of the query that returns a list of clients for the drop-down and make it the default selection. Then handle it in your main stored procedure that if "All" was selected, you don't filter by clientId, and just get all clients.

How to match text to a defined numeric value

I have a database that has a bunch of survey data that I would like to work with. For several questions, the values are things like "Very important","Not at all likely" and I want to create a calculated field to assign a numeric value to these responses.
I don't want to replace the responses at all since I am going to have a user fill out a form to append the data set. I do want to have a calculated field that will automatically assign a numeric value to a text response.
I would just use a vlookup or an IF function in Excel to do this, but the problem is that Excel can't handle as much data as Access can. I need to set it up so that all Excel will house is a pivot table from the Access database.
Could anyone please tell me if there is a good way to do this? I am just not sure how to do it.
Create a new table with 2 columns: user_value (text) and numeric_value (number). Get all of the user entered values uniquely from the user entered data table with a query (the sigma symbol gives you a group by query). Put these in your new table and assign a numerical value to them. Then you can create an output query which joins your data to the lookup table and retrieves the numerical value for each user entered value.