Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Values In Multiple Areas Problem


I’ve a range consist of multiple areas. “D$58:$H$58,D$60:$H$61”
When I count the number of cells it gives the number of cells in the areas (15).
But when loop through the cells(i, j); it is indexing them as one continuous range like “D$58:$H$61”
Is there a way to get only the values of the chosen cells?

thanks in advance




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Multiple Areas Check...
Does not work
Set rngUnion = Range(Array("G11:G279", "J11:J279", "M11:M279", "P11:P279", "S11:S279", "V11:V279", "Y11:Y279", "G285:G303", "G309:H327"))

Does not work
Set rngUnion = Range("G11:G279", "J11:J279", "M11:M279", "P11:P279", "S11:S279", "V11:V279", "Y11:Y279", "G285:G303", "G309:H327")

Works but I need it to include all of the above
Set rngUnion = Range("G11:G279", "J11:J279")

Can this be done???

Select Multiple Areas In A Textbox
Hi,

Can any one let me know, how to select multiple areas in a textbox as we can do in word document. I can select Selecting multiple areas (text) using ctrl button in word document.

Ex.
How to select multiple area.

Select 'How' using mouse, hold control key and select 'multiple' word.
I am using office 2003 and refering to the textbox in user form.

Please suggest any third party control which have this feature.

Creating Multiple Print Areas Automatically Using VBA
I have an Excel file in which a worksheet contains 365 identical tables
except for the date.

I wish to make all these tables individual print areas i.e end up with 365
print areas.

I wish to do this automatically using VBA code.

My only attempt to was use the following code on each table using a loop.

Sub PrintArea()

Application.ScreenUpdating = False

Worksheets("Sheet1").Activate

For t = 1 To 13141 Step 36

Range("A1")(t).Activate

ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address

Next t

Application.ScreenUpdating = True

End Sub

I used Step Into to view the operation of the code one line at a time.

Unfortunately as soon as the second table became a print area the first
table print area was deselected
As soon as the third table became a print area the second table print area
was deselected and so on.

The result of running the code was simply to make the last table a print
area.

Any suggestions please ?

I am quite willing to upload a copy of the file if this is at all possible

Sending Values Multiple Values To ONE Word File[Resolved Like A Horny Ho']
I have searched for how to do this and have the code to start up a word app: (thanks to Carl)

Option Explicit

VB Code:
Private Sub Command1_Click()    Dim WordApp As Word.Application    Set WordApp = New Word.Application    With WordApp        'create word app from default template        .Documents.Add "Normal.dot"        'don't ask me to save before quiting!        .DisplayAlerts = wdAlertsNone        'show the word window        .Visible = True        'active the window        .Activate        'send text to the window        .Selection.Text = "Hello World!"        'print the page        .PrintOut        'wait for document to print before quiting        Do While WordApp.BackgroundPrintingStatus        Loop        'quit        .Quit    End With    Set WordApp = Nothing    End Sub


But what I need to do is have users check the fields who's values they want to include in a report and have the word file as the report. Here's a GIF of what I mean:

The checkboxes indicate the values and field names to be included in the word document.
Does anyone know how to do this/a tutorial for this?
thank you xxxx

Updating Multiple Records Using Single Field Multiple Values..
dear

i have a flex in whcih i am displaying records.

lets say there are 5 records in the flex, with srno 1, 2, 3, 4, 5 and out of these 5 records i want to update 3 records srno 1, 3, 5.

srno date

1 01/12/2005
2 02/12/2005
3 10/12/2005
4 10/12/2005
5 11/12/2005

Like in delete statement we use this syntax.

delete * from tablename where fieldname in ("fieldvalue")

can we use the same concept for updating single field date in my case

can we use update like given below

update tablename set date = " & "'" & Format(Date, "dd-MM-yyyy") & "'" & " where srno in ("1,3,5")

But even after using the above syntax my data is not updated and also im not getting any error msg

hope to get helpful replies

regards

ladoo

Multiple Values
Inserting multiple values... what would be the best way to do this?

MyConn.Execute ("INSERT INTO Student(Firstname, Lastname) VALUES ('" & strfirstname & strlastname & "')")

getting "Number of query values and destinations not the same" error.

thanks in advanced.

Multiple Values
Does anyone have any insight on getting Crystal Reports to allow for multiple values when used in conjunction with a stored procedure? I am preparing a report that is focused on vendor numbers. The user wishes to be able to search by either one vendor, multiple vendors, or all vendors. The way I prepared my stored procedure allows for all vendors or for a single vendor, but I can't seem to get Crystal to allow for multiple vendors. Does my question make sense, and is there a work around for this problem?

How Can I Compare Multiple Values At Once?
Is there a comparison operator or keyword that can compare multiple cells/values at once? What I mean is, I have to execute code IF ALL instances of a cell value are equal.

Actually it's IF value x repeats Then FOR EACH INSTANCE of value x(could be 2, could be 5 or more...) - IF Value y(13 cells over) is equal(in each record/instance of value x), THEN Do something...

I am new and cannot seem to do it with just If-Then statements....

Thanks for any help!:wall:

Multiple Values In A Cell.
Is it possible to store multiple values in a cell but only display one of them?

Sum Multiple TextBox Values
Hi,

Any help would be appreciated. I've created a form to be used in conjunction with a worksheet. The worksheet has a sum function for the range total, but I'd like to sum the textbox values on the form in order to validate the range total. I've looked around on the site and found mulitple threads on the subject, but I can't seem to get any to work. The form has about 40 textboxes, with most formatted as currency. I'm a newbie so the more detail the better. Thanks in advance.

Multiple Values From A Function
Hi everyone.

In my app I have numerous places where the code draws a line on a background picture box, using some (not really complex, but tedious) trigonometry to calculate where to put it. The calculations take three inputs - an angle and two offsets - and calculate the four values X1,Y1,X2,Y2 that represent the co-ordinates of the two ends of the line.

At the moment, the calculations are actually typed out in the procedure for every instance of drawing the line. I wanted to change it to put the calculations in a function that would return the four variables, but it seems from my reading that a function can return only a single value, named with the name of the functon.

Is there a way to get four values back from a single function call, or is there a different way to approach encapsulating this trig?

Richard

Multiple Values For A Variable
Hello World!

I am looking for a way to make a variable have multiple values, but not really like an array...for example:

Blah = 25,200,0,1,rgb(0,0,255),0,0,0)

right now the way I have stuff done is really bulky, but if I could do that, I could reduce my stuff to a few lines of code...any suggestions??

Assign Multiple Values
assign multiple values to a lable (or button)

Hi, I have a question. I'm new to visual basic programming and I'm stuck at something. How can I assign multiple values to a single lable. forexample, a lable has 3 values stored and when i click once i get A and if i click twice i get B three time C.. etc sorta like a mobile phone button function. How can I do it?? what functions do i need to learn to be able to do it.. thank you so much for the help. much appreciated

Passing Multiple Values Into A Sub
I can't figure this one out.


VB Code:
Private Sub potFlop(ByVal call as Integer, pot as Integer, river as integer)


It asks for an identifier..?

Saving Multiple Values
Hey guys, I was wondering if anyone can suggest the best way to save a large number of variables and call them back again. (And by suggest I mean a tutorial or link to a tutorial as well :P)

Thanks in advance.

How Do I Return Multiple Values?
I tried making a function that took 4 varibles ByRef in hopes that function could change them and when the function ended the new values would be back in the caller function. Like a reference should, right?

Is there anyway to get this done?

Thanks,
NOMAD

Multiple Combos In IE With Same Values
I posted this in the ASP forum.. but no one browses it
sorry for posting it here.. but my boss wants this done ASAP

I have an ASP page that I need to load 14 combo boxes with the same table from a database... I don't want to have to open the recordset 14 times... so if I load the first combo.. how can I copy all the elements of the drop down to the other combos.. this is only from IE 5.5+ so I can use client side VBScript....

Multiple Values In A Field
Hi,

  I have a database that needs to store (and search by) invoice numbers. I was just going to use a field called 'Invoice_Numbers' however I've found out that there may be multiple invoice numbers accosiated with each record.

  How do i store multiple values in a field and be able to search the database for them?

  I can just have multiple fields like 'Invoice_Number_1' , 'Invoice_Number_2' etc as I don't know how many invoice numbers there may be!!


  If you can help I would be very greatfull!

How To Add Multiple Values In One Field
my program is goingto be used to monitor the sales and inventory of a certain company. in entering the purchase of a customer, i first add all items to be purchased on a listview. then i would like to add to the database the items purchased. my problem arises when the customer purchases several items. how would i enter the products purchased into the database if there are more than 1 item purchased? I need a way to add the products purchased under one transaction.

my database contains the following fields:
transaction_id - primary key
customer_id
purchase_date
product_id
quantity_purchased
mode_of_payment

i have included a screenshot if it helps. any help would be greatly appreciated.



Edited by - LiquidAngel on 8/25/2003 11:57:42 AM

Multiple Values For One Field In SQL
I am kind-of-new to SQL and how they work.
I have two tables in an Access database, I want to do a sql search in table1 to get a list of values to look up in table2.
Table1 has Fields (CustomerName)(Route)(FuelSurCharge)

Table2 has Fields (Route)(RunValue)(DateValue)

Table1 allows the user to assign a CustomerName to a Given Route, that customer name can be assigned to many different Route's.

Table2 is the main Database which keeps the Route and RunValue.

My SQL needs to be able First look up from Table1 all Routes that are assigned to a CustomerName then from table 2 look up all the Route values with that Route name.

I tried to create part of the Sql statement and appending to the final sSQL statement like so...

SQL = "Select * From Table1 Where CustomerTable.Customer Like '" & CustomerNameStr & "';"

cnt = 0
If Len(CustomerNameStr) > 0 Then
Set rsAccess2 = New ADODB.Recordset
rsAccess2.Open SQL, objAccessConnection, adOpenKeyset, adLockOptimistic
While Not rsAccess2.EOF
cnt = cnt + 1
If cnt > 1 Then
Croute = Croute & " And Like " & rsAccess2!Route
End If
If cnt = 1 Then
Croute = rsAccess2!Route
End If
rsAccess2.MoveNext
Wend
rsAccess2.Close
End If

sSQL = "Select * Table2 Where Table2.DateValue >=#" & stStartDate & "# and Table2.DateValue <=#" & stEndDate & "#"
sSQL = sSQL & " AND Table2.Route Like '" & Croute & "'"
sSQL = sSQL & ";"

I have much more information in the Tables then what I have shown but this give the general ideal.

I'm not sure if I am using the AND correctly or if there is better way to do this.

Thanks!

Sending Multiple Values Through Winsock??
Through my searching into the tutorials and programs on the internet, i noticed that all examples concerning WINSOCK (in visual basic 6) talks about sending one value from client to server.

I wonder if there is a way to send multiple values , coz i have the following task:

I have 3 text boxes in the Client program , using winsock , i want to send these 3 values to another 3 text boxes in the Server program with just one click of "Send" button.

if any body can help with the code i will be grateful

Looking Up And Comparing Multiple Values/conditions
I have a project I am working on that involves, mailing letters based on what health plan the consumer is on (I work for an HMO). But it doesn't end there. There are 3 different "plan" letter versions, but also 3 versions of each (one for adult individual, one for child, and one for entire family).

I get the data from a sql query I run which tells me the plan, age, etc...

I am at a loss, however, on how to state: "If the subscriber # shows up more than once, AND all instances of it show the same Dr. #, then send family letter. (We have codes to refer to each letter version). Otherwise it is just and individual letter OR a child letter based on the age of consumer and based on the plan name....

I assume it will be some kind of array?

Does this make sense? Can anyone help? Thanks.

Problem With .Find Multiple Values
Hi everyone,

at the moment, I'm using the Find method to find a specific value (1) in a column, then copy the entire row and paste it to another sheet, using:

With Worksheets("Sheet1").Range("G2:G1000") 'UsedRange
Set c = .Find(1, LookIn:=xlValues, LookAt:=xlWhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.EntireRow.Copy
Worksheets("Sheet2").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Select


Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

My problem is that I now want to find multiple values. That is, anything greater than zero. Is there a way that I can replace the "1" in my find method to do this?

Sharing Values In Multiple Forms
In my application, a second form opens up and asks the user for some information (3 integers) which is input into 3 seperate textboxes. I need to use these values in the original form but for some reason when focus goes back I keep getting a all values of zero. How do you pass values from form to form?

How Do I Accomplish The Corresponding To Multiple Values In Listbox?
Hey!
As a total newbie I'm trying to develop a program to sort different kinds of data in Access DB.
My first form is supposed to administrate the different categories that the data is sorted under. Now I want dynamic subcategories, meaning any category can be set as a subcategory to another (tho only to one). This rendering the possibility of a infinite number of levels.

Coming from PHP my solution to this was to simply have a table with CatID, CatName and CatParent. A subcategory would then simply have it's parent's ID set in the CatParent column.
I've added some categories from Access in order to start making the inteface used to update categories and I've created a listbox that is populated by this code:

General declarations:

Code:
Dim MyConn As ADODB.Connection
Dim rsCategories As ADODB.Recordset
Dim strLevelDots As String


Private Sub Form_Load()
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "Notes2.mdb;"
MyConn.Open
Set rsCategories = MyConn.Execute("SELECT CatID, CatName FROM Categories WHERE CatParent = 0")

Do While Not rsCategories.EOF
lstCategories.AddItem (rsCategories("CatName"))
strLevelDots = ""
FindChildren (rsCategories("CatID"))
rsCategories.MoveNext
Loop

End Sub

Sub FindChildren(intParentID As Integer)
Dim rsChildren As ADODB.Recordset
Set rsChildren = MyConn.Execute("SELECT CatID, CatName FROM Categories WHERE CatParent = " & intParentID)
strLevelDots = strLevelDots + "..."
Do While Not rsChildren.EOF
lstCategories.AddItem (strLevelDots & rsChildren("CatName"))
FindChildren (rsChildren("CatID"))
rsChildren.MoveNext
Loop
End Sub

What this code does is to first find all categories that don't have a parent. For each of those the FindChildren()-function is called. The function then finds all children to the category, add's them to the listbox with three dots in front of them and then calls itself again, finding the childrens of that specific children/parent.

So far so good. I dunno if the code is good but atleast it does what I want.
Now my problem is this: When the user selects a category from the listbox I want other fields populated by that categorys data from the DB. I could just use the Replace function and parse away the dots and select the categorys data with the cat's name. However, I want it to be possible to have several categories with the same name, so in some way I need to be able to pass the categorys ID instead of the name from the listbox. How would I go about to do this? Coming from webdevelopment I would simply just assign the ID to the dropdowns value, but as I understand it the value and what's displayed in the listbox is the same?

Thanks in advance for any help,

Paste Values For Multiple Sheets
I am trying to write a command that will unprotect all worksheets, copy all cells on each worksheet, paste the values on the same sheet (replace any formulas with their values), re-protect all worksheets and then save the file. The code I am using is below. The protect, unprotect, and save all work fine. What I can't get to work is the copy and paste. It will only copy and paste the active sheet and will not switch to the next sheet. I am not an expert in VBA by any means, so this may be an easy fix.
Help!

Sub CommandButton1_Click()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect Password:="password"
Next ws

Application.ScreenUpdating = True

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Activate
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Next ws

Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Protect Password:="password"
Next ws

ActiveWorkbook.Save

End Sub

Assign Multiple Values To An Array
I'm wondering how you assign multiple values to an array at one, i think in c++ and java it's along these lines for example:

myArray() = {1,2,,3,5,2,4,7,,8}

can you do similar to this in vb on 1 line?

Listview With Multiple Field Values
I have a listview that is populated from a certain table. I only want to display items within the listview that appear more than once. Here's the code for populating the listview with all the field values, but as I said I just want the ones where the id appears more than once. Can someone help?


Code:
Set rsAreas = New ADODB.Recordset
Set rsAreas = xData.AllTableRecords(GetDL(), GetIC(), "areas", "id,descript", False, True, "id")

Dim itmX As ListItem
While Not rsareas.EOF
If Trim(oAll.ReturnFieldValue(rsAreas!id)) <> "" Then
Set itmX = oMyForm.lvwLetters.ListItems.Add(, , Trim(rsAreas!id))
If Trim(oAll.ReturnFieldValue(rsAreas!descript)) <> "" Then
itmX.SubItems(1) = Trim(rsAreas!descript)
End If
End If
rsAreas.MoveNext
Wend
rsAreas.Close
Set rsAreas = Nothing
Exit Sub

Multiple Variant Values To One Variable
How could I store multiple values of any type to one variable?
I also am wondering, if at times I could just use one of these variables.
Thankx a lot!

Multiple Values For Crystal Rpt Paramaters?
Hey all.. i'm writing a visual basic program that incorporates crystal reports. I've added a paramter to the report and i wrote some code so the user isn't prompted for the value of the paramter. the code is as follows

Set crpParamDefs = m_crReport.ParameterFields
For Each crpParamDef In crpParamDefs
Select Case crpParamDef.ParameterFieldName
Case "[THE_NAME_OF_YOUR_PARAMETER]"
Call crpParamDef.SetCurrentValue([THE_VALUE_TO_SET_IT_TO)

End Select
Next crpParamDef

Here is the problem.. when i setup the paramater i set it up to allow for multiple values... but it appears SetCurrentValue only allows 1 value.. how can i pass the paramater more than one value in VB? Thanks a lot to all replies

Average Of Multiple Values On Form
in access:

have a form which displays 10 values, linked to 10 different fields in table. Sometimes numbers are entered into all 10 fields, other times only some of the fields will have numbers entered.

I want to be able to display the average of the values entered into the 10 fields, remembering that some of the fields may be blank, so a simple (field1 + field2 + ... + field10) / 10 will NOT give the correct result.

As I understand, the avg function can only work on single fields in this situation. Is this correct?

Please help!

Multiple Values For An Item In A Combo Box
Hey Guys,

Is there any way to have a multiple value for an item in a combo box, i.e: like in HTML when you have a form item
<select name="combo">
<option name="item1" value="1">Item1</option>
</select>

The display name is Item1 but the value of this item is actually 1, can this be done in vb?
I'm populating a combo box from a database and I want the string to appear for the item in the list but I want it's id to actually be the value.

sorry for the HTML code, but it's an easy way to explain the problem.

thanks!

Crystal Reports 7; SP's And Multiple Values
I have noticed in Crystal Reports 7 that when I use a stored procedure that I am not allowed to select multiple values in my parameter fields. Does anyone know a work around to this problem???

Dictionary Object With Multiple Values
Hi,

Is there a way to have more than one value in a dictionary object? Currently, I know it works like key, value. But I have a few more values i'd like to associate with the key. Is there a way to go, key, value, value? I know I could probably have the value an array and that would work, but I thought i'd get some input here first.

Thanks,

Pass List Of Multiple Values
I am trying to write a function that will enable and disable buttons that are in an array

i thought I could do something like this

Code:
changebuttfunc (1, 2, 3, enable)


only thing is how do I pass a list of numbers like this? the number of buttons may change when callinig at different points of the prog
i.e. i may want to change 3 buttons then 6,
would I have to write my function to accept seperate integer values
like

Code:
changebuttfunc (but1 as integer, but2 as integer, etc)

up to the max amount of numbers and then just leave a load of commas in for the values I do not wish to change or maybe I should pass them as a comma seperated string and split it inside the function?

any input appreciated ta

Return Multiple Values From Function
I have created a function that takes a date as its argument and I want it to return 3 values (month, Quarter, Financial Year).

The code itself works fine (I have tested it using msgboxes) However I need to actually return all 3 values, and I cannot see how to do this with a simple function.

Do I need to use Property Let/Get, or a class?

Thanks

Francis

ASCII Values Of Multiple Keys?
Hi,

I have a question that I've been unable to find an answer to. I want to know how I can find out the ASCII value when the CONTORL key is held down, and another key is pressed. The only one that I know, is that CONTROL + ENTER is 10. How can I determine what CONTROL + B or any other key is so I can check to see if the user presses this combination? Thanks in advance.

Return Multiple Values From A Function?
Can you return multiple values from a function? and if so how? can you return an array?


THANKS FOR YOUR HELP AGAIN GUYS!

Returning Multiple Values From A Function
How can I send a string to a function e.g.

12 February, 2001

and have it return the 3 values:

day = 12
month = 02

and

year = 2001

?

HELP With Returning Multiple Values To A Textbox!!!
Basically I have a query that I want to output to a textbox (list box will work, although I HAVE to use the text box). I want the textbox to output all of the records in the query into the textbox like this(record amount will vary)…

A B F FREIGHT SYSTEM (-3), ALLIANCE SHIPPERS (20), HUB GROUP (65), ROADWAY EXPRESS (56),
MAERSK LINE (-4)

Currently is it only outputting like this…
A B F FREIGHT SYSTEM (-3)


The code I currently have is

Quote:
Private Sub Command30_Click()

CUSTOMERS.Value = DLookup("[Account] & ' ' & '(' & [VAR] & ')' ", "Customer Variance")

End Sub
I know DLookup only returns one value, so I’m thinking I need to make a loop but I don’t know how to go about this. So if someone could give me an example or help that would be great!!!

PS. The query uses critera from the form, so I have to click a button that will run the query. And the table has thousands of records so it would take to long if I directly linked it to an object.

Save Multiple Values In One Variable
This has probably been asked and answered, but I could not find anything. Anyway, here's what I want to do:
I have a button that's randomizing values that are shown in a TextBox. What I want to do is to prevent the same value form showing up again. I know that I somehow should be able save the values to a variable, like

Private used_values(1 To 100) As Integer

search through the variable with a for loop and if the randomized value is already in the variable I just have to randomize again till i get a value not previously displayed. The thing is, I don't know in detail how to do this so an explanation would be greatly appreciated.

----------------------
Using VB 6.0 (SP5)

Edited by - ATIKO on 6/2/2005 3:41:31 PM

Bitmasking (Sum Of Values = Multiple Settings)
I'm working on database-driven permission settings. Instead of having multiple fields for each permission type, I'd like to do "Sum of Values" (forgot the technical term) for each area requiring permissions. The permissions are:


Create
Read Own
Read All
Modify Own
Modify All
Delete Own
Delete All
Possibly others...


By "Sum of Values", I mean something like the runtime knows that a provided value of 291 for MsgBox translates to a Yes/No/Cancel Question with No as the default button (3 + 32 + 256).

I need information on how to provide numbers for such a system (what's the incrementing?) and then how to translate it back out to the individual values (how do I know that 291 is 3 different values?).

Any help would be appreciated.

[Edit 12/06/04 12:19 PM ET - Changed title to indicate Bitmasking]


* Out of courtesy, please mark your topics as Resolved (click for quick tutorial)
* Posting Guidelines - Format your posts! - My FAQs - Search Forum - FAQs
* A Class module replacement for the FileSystemObject
* An Interesting Read: How To Ask Questions The Smart Way

Edited by - AbbydonKrafts on 12/6/2004 9:22:20 AM

Multiple Listbox Values. How To Store Them?
Hello Again....I appologize for reposting this message again...didn't post it in the correct place at first. Sorry about that.
Can anyone help me with this access problem that I am having ?
Here is a brief description of what I would like:


I have 3 tables.
1- tbl-customer contains(customer-id, customer-name)
2- tbl-serials contains(serial-id, serial-description)
3- tbl-customerSerial contains(Customer-id,serial-id)

I have created a form that contains the customer info, and
I would like to add a listbox that outputs all the
available (predefined values) serial descriptions for that
particular customer. now, a customer can have multiple
serial numbers. I would like to store the values chosen in
the listbox in the tbl-customerSerial table.

I have searched online for references about this but
unfortunatly couldn't find anything .

Does anyone know how is this possible?
I appreciate all the help.
Thank you in advance.

Combobox Populating Multiple Values
I am using vb6 and connecting to an Access 2003 database using as Adodc connection. The form has textboxes that are blank until a search is conducted. Then the user can edit that record. When the Edit command is selected the textbox for 'Location' is hidden and a combobox becomes visible with the record and a dropdown of one of each other possible choices from the list in the database. For example the user pulls up a record with a location of 'Overhead' and selects Edit; the combobox displays 'Overhead" and in the dropdownbox shows "Storage Area' & 'Overhead' for the other choices. It works fine, but I have found if you select the Undo command to back out of the edit and then select Edit again then the combobox displays the location And the dropdown shows the choices twice. Ex: dropdown - 'Storage Area', 'Overhead', Storage Area', Overhead. If you select Undo and then Edit again there are 3 times as many and so on and so on. This is my Edit code and Undo code below. I have tried resetting the sql, combobox to nothing when the command is first selected in hopes that is would clear anything out, but that doesn't work. I just can't figure it out.
Code:
Case cmdEdit
        bopen = 1
        byeditaddmode = 2
        If MyRecSet.State = adStateOpen Then
        With MyRecSet
            If (.EditMode = adEditNone) Then
                If (.RecordCount > 0) Then
                    vMyBookMark = .Bookmark
                Else
                    vMyBookMark = ""
                End If
                Dim strcombo As String
                    strcombo = ""
                    strcombo = Text1(2).Text
                With Combo1
                    Set MyRecSet = Nothing
                    MyConn.Close
                    Set MyConn = Nothing
                    MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:Tempvb_projectsTest ProjectsBilling_Schedule_Inventoryparts.mdb;"
                    MyConn.Open
                    strSQL = ("SELECT DISTINCT Location FROM Parts")
                    MyRecSet.CursorLocation = adUseClient
                    MyRecSet.Open strSQL, MyConn, adOpenStatic, adLockPessimistic
                If MyRecSet.EOF = True Then
                    MyRecSet.MoveFirst
                End If
                Do While Not MyRecSet.EOF
                    Combo1.AddItem MyRecSet.Fields.Item("Location").Value & ""
                    MyRecSet.MoveNext
                Loop
                End With
                If MyRecSet.EOF Then
                    MyRecSet.MoveFirst
                End If
                For intLoop = 0 To 7
                    If intLoop <> 2 Then
                    Text1(intLoop).Locked = False
                    Text1(intLoop).BackColor = vbYellow
                    End If
                Next
                Combo1.Visible = True
                Combo1.BackColor = vbYellow
                Combo1.TabIndex = 2
                Combo1.Text = strcombo
                Text1(2).Visible = False
                navigateButtons ("00110010")
                Text1(0).SetFocus
            End If
        End With
        Else
            strcombo = ""
            strcombo = Text1(2).Text
        With Combo1
            MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:Tempvb_projectsTest ProjectsBilling_Schedule_Inventoryparts.mdb;"
            MyConn.Open
            strSQL = ("SELECT DISTINCT Location FROM Parts")
            MyRecSet.CursorLocation = adUseClient
            MyRecSet.Open strSQL, MyConn, adOpenStatic, adLockPessimistic
                If MyRecSet.EOF = True Then
                    MyRecSet.MoveFirst
                End If
                Do While Not MyRecSet.EOF
                    Combo1.AddItem MyRecSet.Fields.Item("Location").Value & ""
                    MyRecSet.MoveNext
                Loop
        End With
            If MyRecSet.EOF Then
                MyRecSet.MoveFirst
            End If
            For intLoop = 0 To 7
                If intLoop <> 2 Then
                    Text1(intLoop).Locked = False
                    Text1(intLoop).BackColor = vbYellow
                End If
            Next
                Combo1.Visible = True
                Combo1.BackColor = vbYellow
                Combo1.TabIndex = 2
                'Combo1.Text = strcombo
                Text1(2).Visible = False
                navigateButtons ("00110010")
                Text1(0).SetFocus
    End If
Case cmdUndo
        bopen = 1
        With MyRecSet
            If (.EditMode <> adEditNone) Then
                .CancelUpdate
                For intLoop = 0 To 7
                    If intLoop <> 2 Then
                    Text1(intLoop).Locked = True
                    Text1(intLoop).BackColor = vbWhite
                    Text1(intLoop).Text = ""
                    End If
                Next
                Combo1.Visible = False
                Text1(2).Visible = True
                Text1(2).Locked = True
                Text1(2).BackColor = vbWhite
                Text1(2).Text = ""
            Else
                .Move 0
                For intLoop = 0 To 7
                    If intLoop <> 2 Then
                    Text1(intLoop).Locked = True
                    Text1(intLoop).BackColor = vbWhite
                    End If
                Next
                Combo1.Visible = False
                Text1(2).Visible = True
                Text1(2).Locked = True
                Text1(2).BackColor = vbWhite
                Text1(0).SetFocus
            End If
            If byeditaddmode = 1 Then
                navigateButtons ("11000010")
            Else
                navigateButtons ("11001111")
            End If
        End With
        
            MyRecSet.Close
            Set MyRecSet = Nothing
            MyConn.Close
            Set MyConn = Nothing
            
            byeditaddmode = 0

Any ideas what is going on? Thanks.

Inserting Multiple String Values
I have an SQL Server table named Order_Starters that contains two columns, OrderNo and OrderItem.

My problem is that I need to insert four strings into OrderNo:
strOrderNo1, strOrderNo2, strOrderNo3, strOrderNo4

and four strings into OrderItem:
strOrderItem1, strOrderItem2, strOrderItem3, strOrderItem4

Is there anyone who can give some assistance with this problem?

Regards

Find Values In Multiple Columns.
Hi guys.

My client has double backed on what they want and i'm starting this project again.

I'm trying to loop thru a range and count the matches.

Example.

Loop Column A and count all values which have "A" as value
Set the count value as a label1.caption

Loop Column B for value of "1" and Column A value of "A"
set the count value as label2.caption

Loop Column C for value of "1","4" or "2","8","9" or "3","5" and column A value of "A" and column B value of "1"
set the count value as label3.caption


this is then repeated for Column A value of somthing else but the Column B and C will remain the same.
I've tried with If statements and failed, im now trying with select cases.

Code:
Public Sub Basic()
    ActiveWorkbook.Sheets(1).Select
    Dim col As Integer
    Dim cel As Range
    Dim SelRange As Range
    Dim SelRange2 As Range
    Dim SelRange3 As Range
    
    Dim totalrows As Integer
        For col = 1 To 1 'columns A to A
        For Each cel In Range(Cells(1, col), Cells(65536, col).End(xlUp))
            Select Case cel
                Case 1
                    Select Case cel
                        Case 1
                            If SelRange Is Nothing Then
                                Set SelRange = Range(Cells(cel.Row, 1), Cells(cel.Row, 52))
                                totalrows = SelRange.Count
                                BacklogFinder.lblfreqtotal1.Caption = totalrows
                            Else
                                Set SelRange = Union(SelRange, Range(Cells(cel.Row, 1), Cells(cel.Row, 52)))
                                totalrows = SelRange.Count
                                BacklogFinder.lblfreqtotal1.Caption = totalrows / 52
                            End If
                    End Select
                Case "2"
                    Select Case cel
                        Case "2FBARS2"
                            If SelRange2 Is Nothing Then
                                Set SelRange2 = Range(Cells(cel.Row, 1), Cells(cel.Row, 52))
                                totalrows = SelRange2.Count
                                BacklogFinder.lblfreqtotal2.Caption = totalrows
                            Else
                                Set SelRange2 = Union(SelRange2, Range(Cells(cel.Row, 1), Cells(cel.Row, 52)))
                                totalrows = SelRange2.Count
                                BacklogFinder.lblfreqtotal2.Caption = totalrows / 52
                            End If
                    End Select
                End Select
        Next cel
        Next col
end sub


notice the / 52 after the totalrows.
This is because is makes a union of all 52 columns which is needed for the future part.

The future part is to copy all the matching rows and paste them into a spreadsheet.

I divide by 52 as if it finds a match for cell value the union binds teh cells which total 52 and make a boo boo of the overall count.

ANy ideas would be great.

Al

http://www.stormitsolutions.com
http://www.stormitsolutions.co.uk
Allan Nisbet - Web & Software Developer
VB *.*, PHP, D/HTML, VBScipt, ASP, CSS, MySQL, Access, MSOffice,

***Please Mark Posts Resolved when you get your answer***

SQL is the Devil!

Edited by - Big Al Inc on 8/30/2007 7:23:23 AM

Pick Multiple Values In A Combo Box
Hi,
 
   I have a combo box that has a list of majors and the user would like to pick multiple majors when doing a search. This is an access database. I am not sure how I can have the user hit the ctrl key on the keyboard and select multiple majors. Any help will be appreciated. Thanks




Edited by - str50 on 6/18/2008 11:25:42 AM

Reading Multiple Registry Values
Hi all, i'm trying to make a program which detects what plugins for internet explorer you have installed.
My problem is that in reading the registry i need to get the clsid of each plugin, which is not stored in the data section of a binary value, but as the name. All functions i've found only allow you to retrieve information from the data given the entire key.

I need to know how i can retrieve all names and data from a key given only the key name?

Hope this makes sense and someone can point me in the right direction
Thanks

Rich

Query Database With Multiple Values
Hello Everyone,
I have a database in Access 97/2000. I want to query one of the tables, with multiple values for a single field. I am planning to have a single text box, with the required values in that. Individual values will be separated by comma.
For example, previous experience of employees (in number of years) is a column in the table. I want to know the names of employees who has work experience of X, Y and Z with an variation of ,say,N months. I want to put the values in the textbox of the search form as X,Y,Z and then initiate the search. The idea that I had was to separate X,Y and Z with the help of splitting the string value of the textbox entry and then run the search. Since the values can have spaces in between (typing mistakes) and the number of input values can vary, I an not able to implement it.
Can anyone please help, Please?


GeoNav

Copyright © 2005-08 www.BigResource.com, All rights reserved