Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Fix country part 1

Posted on 2011-03-05
6
Medium Priority
?
258 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 46

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 46

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 46

Accepted Solution

by:
aikimark earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

916 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