Thanks everyone for the help. Â Doing the new layer was perfect, because I had no C# code on this form and I wanted to keep all the rest of my customization.
In addition, the code to get access to the txtKeyField worked perfectly. Â
<div>
<p>I never really understood the valve of that button. When I first got into Epicor I thought it would allow me to segregate code (somewhat like classes). Now I have forms with 2000+ lines of code. So much fun to work with in Epicor’s fancy notepad-lite scripting tool…
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com]
Sent: Thursday, August 14, 2014 10:22 AM
To: Vantage
Subject: Re: [Vantage] Converting VB to C# and updating outside table
The new code layer button does not retain your previous code. It's a completely new code base with the same controls
We've got code to generate the next available number for a couple of forms from a long time ago. Â I'm trying to do something similar for 2 new forms we've made, but the new forms are in C# and the old are in VB.
Historically I've gotten away with just using an online converter. Â Unfortunately that's not working today. Â When I use it, I get this error:
I'm hoping someone knows the right code to update the company.number04 field from C# or they can review the code below to identify the issues. Â I'm getting the errors within the "if (found)" section.
C#:
 private void epiButtonGenNCRNum_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
txtKeyField.Text = GetNextKey();
}Â
private string GetNextKey()
{
////Use the company Adapter to Store our sequence number Number01
string nextKey = string.Empty;
CompanyAdapter companyAdapter = new CompanyAdapter(UD08Form);
<div>
<p></p><div dir="ltr"><div style="font-family:arial, sans-serif;font-size:13px;">We've got code to generate the next available number for a couple of forms from a long time ago. Â I'm trying to do something similar for 2 new forms we've made, but the new forms are in C# and the old are in VB.</div>
Historically I've gotten away with just using an online converter. Â Unfortunately that's not working today. Â When I use it, I get this error:
I'm hoping someone knows the right code to update the company.number04 field from C# or they can review the code below to identify the issues. Â I'm getting the errors within the "if (found)" section.
C#:
 private void epiButtonGenNCRNum_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
txtKeyField.Text = GetNextKey();
}Â
private string GetNextKey()
{
////Use the company Adapter to Store our sequence number Number01
string nextKey = string.Empty;
CompanyAdapter companyAdapter = new CompanyAdapter(UD08Form);
John thanks for the reply, that got me much further. Â I now have the following issues, I hope someone can help narrow these last few issues down?
 Error: CS0103 - line 57 (2178) - The name 'txtKeyField' does not exist in the current context
 Error: CS0117 - line 69 (2190) - 'object' does not contain a definition for 'CompanyID'
 Error: CS0149 - line 73 (2194) - Method name expected
 Error: CS0149 - line 75 (2196) - Method name expected
Line 57:txtKeyField.Text = GetNextKey(); Â Â Â ---- This field does exist, don't know why it says it doesn't exist in current context?
Line 69:string company = UD08Form.Session.CompanyID; Â Â Â Â Â ----- I can force this but then it won't work for multi-company (not a big deal as we're single, but I can see us perhaps moving to multi in the semi-near future)
Line 73:nextKey = companyAdapter.CompanyData.Company.Rows[0]("Number04").toString();
Line 75:companyAdapter.CompanyData.Company.Rows[0]("Number04") += 1;
Lines 73 & 75 are the most important, they're what makes everything work.
<div>
<p></p><div dir="ltr">C# uses square brackets for indexing rather than parenthesis.<div>This:</div><div><div><div style="font-family:arial, sans-serif;font-size:13px;">nextKey = companyAdapter.CompanyData.Company.Rows(0)("Number04").toString();</div>
<div>
<p></p><div dir="ltr"><div style="font-family:arial, sans-serif;font-size:13px;">We've got code to generate the next available number for a couple of forms from a long time ago. Â I'm trying to do something similar for 2 new forms we've made, but the new forms are in C# and the old are in VB.</div>
Historically I've gotten away with just using an online converter. Â Unfortunately that's not working today. Â When I use it, I get this error:
I'm hoping someone knows the right code to update the company.number04 field from C# or they can review the code below to identify the issues. Â I'm getting the errors within the "if (found)" section.
C#:
 private void epiButtonGenNCRNum_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
txtKeyField.Text = GetNextKey();
}Â
private string GetNextKey()
{
////Use the company Adapter to Store our sequence number Number01
string nextKey = string.Empty;
CompanyAdapter companyAdapter = new CompanyAdapter(UD08Form);
<div>
<p>Have you tried the "New Code Layer" button in the Script Editor? It allows C# code to be added while VB exists and vice verse<span>Â Â Â Â </span><span><span>Â Â Â Â </span></span></p>
</div>
<div style="color:#fff;min-height:0;"></div>
For the "txtKey does not exist", you could use GetNativeControlReference to declare it before you use it, just grab the EpiGuid from the field's properties and put it in (it will look something like this "f1260502-8d42-47fd-a148-0f66da3846fe"
Exampe:
Dim tbxJobNum as EpiTextBox = CType(csm.GetNativeControlReference("f1260502-8d42-47fd-a148-0f66da3846fe"), EpiTextBox)
So yours would be
Dim txtMyRedeclaredKeyField as EpiTextBox = CType(csm.GetNativeControlReference("[your fields epiguid]"), EpiTextBox)
I never really understood the valve of that button. When I first got into Epicor I thought it would allow me to segregate code (somewhat like classes). Now I have forms with 2000+ lines of code. So much fun to work with in Epicor’s fancy notepad-lite scripting tool…
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com]
Sent: Thursday, August 14, 2014 10:22 AM
To: Vantage
Subject: Re: [Vantage] Converting VB to C# and updating outside table
The new code layer button does not retain your previous code. It's a completely new code base with the same controls