Solved

Fix country part 1

Posted on 2011-03-05
6
236 Views
Last Modified: 2012-05-11
Hello all,

I want to be able to fix the country name in my MSHFlexGrid1.

Let me explain:

In my Grid, in the 5ft column "Origin_Reg_Key", i have multiple type of numbers. 2 of them are 5 and 8.

I need to be able to first, if there is a number 5 or 8 in column 5, then it will look at the first digit from the column 7 "Origin_Reg".

If the first character is a letter, then in column 8 "Origin_Country", it will put "CANADA". If the first character is a number, it will put "USA".

I need to do the same thing with  column 9-11-12.

How can i do this please.

Thanks
Canada-USA.bmp
0
Comment
Question by:Wilder1626
  • 3
  • 3
6 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 35059271
I wrote the following from memory of similar processing and have not tested it against any live data in a flexgrid control.  Please try it to verify (intended) results.
For lngLoop = 1 To MSHFlexGrid1.Rows
  Select Case Val(MSHFlexGrid1.Column(lngLoop, 5))
    Case 5,8
      If IsNumeric(Left$(MSHFlexGrid1.Column(lngLoop, 7), 1)) Then
        MSHFlexGrid1.Column(lngLoop, 8) = "USA"
      Else
        MSHFlexGrid1.Column(lngLoop, 8) = "CANADA"
      End If
  End Select
  Select Case Val(MSHFlexGrid1.Column(lngLoop, 9))
    Case 5,8
      If IsNumeric(Left$(MSHFlexGrid1.Column(lngLoop, 11), 1)) Then
        MSHFlexGrid1.Column(lngLoop, 12) = "USA"
      Else
        MSHFlexGrid1.Column(lngLoop, 12) = "CANADA"
      End If
  End Select
Next

Open in new window

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 35059397
Hello aikimark,

I have an error: Variable nor define on:

For lngLoop = 1 To MSHFlexGrid1.Rows

Should i put Dim lngLoop  as Integer?

If so then i have another error: Method or member of data not found:
Select Case val(MSHFlexGrid1.Column(lngLoop, 5))



0
 
LVL 45

Expert Comment

by:aikimark
ID: 35060822
Yes.  You will need to define a lngLoop variable (as long)

Yes.  That statement should have referenced the text at that location.  When I wrote that, I was referencing your problem description and was thinking in terms of columns.  I didn't adjust the statement when I added the row identifier.
Select Case val(MSHFlexGrid1.Text(lngLoop, 5))

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Author Comment

by:Wilder1626
ID: 35061502
I have changed for
Select Case val(MSHFlexGrid1.Text(lngLoop, 5))

But it does not want to take the .text.

It say: Wrong number of arguments or invalid property assignment.
0
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 35062190
the correct property is TextMatrix
Select Case val(MSHFlexGrid1.TextMatrix(lngLoop, 5))

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 35062284
Oh thank,  Now it is working great.

Thanks again for your help.

I will now create the part 2 of the post topic.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now