This topic is locked

Update two fields

5/14/2007 9:35:44 AM
ASPRunner.NET General questions
H
hoppo1 author

Same Question applies from asprunner - How would you achieve this in asprunner.net?
Thanks

Hello,

I'm just trialling asprunner and would like to know ( and how ) if the following is possible on an access database -
User adds data to a field called "Company" ie Virgin Media once the form is saved Virgin Media is the written to another hidden field in the same database called "SearchCompany" as capitals with no spaces so would be VIRGINMEDIA. In the database there are then two fields -
Company SearchCompany

Virgin Media VIRGINMEDIA
Is this possible? I have tried a few things and so far not had much luck nor has searching returned anything to work on.
Thanks

Hi,

you can do it using Before record added event on the Events tab.

Here is a sample code:
dict("SearchCompany") = Ucase(replace(dict("Company")," ",""))

Eugene 5/14/2007

Try to use this code:
Dim Company As String = parNewValues("Company").Value

parNewValues("Company").Value = Company.Replace(" ","")

H
hoppo1 author 5/14/2007

Thanks for the reply Eugene,
This is the error I get if I try your suggestion -
Error description: An OleDbParameter with ParameterName 'Company' is not contained by this OleDbParameterCollection.
I've added an @ -

Dim Company As String = parNewValues("@Company").Value

parNewValues("@Company").Value = Company.Replace(" ","")


This allows the form to save no error but the only field updated is Company which would update any without this code. Any ideas how to update the SearchCompany field similar to how it's done in asprunner?
Thanks

Eugene 5/15/2007

Sorry, I've made a mistake. Try to use this code:
Dim Company As String = parNewValues("@Company").Value

parNewValues("@SearchCompany").Value = Company.Replace(" ","").ToUpper()

H
hoppo1 author 5/15/2007

Hi Eugene, this is the error the new code generates -
Error description: An OleDbParameter with ParameterName 'Company' is not contained by this OleDbParameterCollection
If i change - parNewValues("@SearchCompany") to parNewValues("@Company") the code works but only changes Company field to uppercase there is nothing entered in SearchCompany field.
I've tried a few variations but not having much luck.
Thanks

Eugene 5/15/2007

Could you please send me your project (including project file, output directory and database backup) on support@xlinesoft.com? I will investigate it on my box.

H
hoppo1 author 5/15/2007

Eugene, I apologise the code does work. I tested on a new Database with only the two fields which worked so I deleted everything I had done so far and started the project from scratch and the code worked on my existing database as expected. I must have set something somewhere which was causing the problem.
Thank you for your help with this.