Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-26-2015, 06:39 AM   #1
prabha_friend
Prabhakaran Karuppaih
 
Join Date: Mar 2009
Location: Chennai
Posts: 360
Thanks: 64
Thanked 3 Times in 3 Posts
prabha_friend is an unknown quantity at this point
Send a message via Yahoo to prabha_friend
Exclamation Aren't the elements of a variant, variants too?

Code:
Public Function RefreshLinks()
Dim myDiag As FileDialog
Dim Files As Variant
Dim Washes As Variant
Dim Temp As Variant
 Files = Array("DEU", "DDE")
Washes = Array("Business Wash", "Corporate Wash", "Coupon Wash", "Dividend Wash")
Set myDiag = FileDialog(msoFileDialogFilePicker)
ReDim Temp(1)
 For Each Temp(0) In Files
    With myDiag
        .Show
    End With
    Select Case Temp(0)
        Case "DEU"
            For Each Temp(1) In Washes
                MsgBox CurrentDb.TableDefs(Temp(1) & "_DEU").Name
            Next element
        Case "DDE"
    End Select
Next element
 End Function
Why am I getting a following error:
Compile error:
Variable required - can't assign to this expression

But Logically its right right? means in a variant array: all of its elements are also variant. But can't I able to use it to assign a variable while looping..?

__________________
Believe in God. See in People. Be a God. Believe in People.
prabha_friend is offline   Reply With Quote
Old 11-26-2015, 06:49 AM   #2
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,568
Thanks: 68
Thanked 2,744 Times in 2,629 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Aren't the elements of a variant, variants too?

should be:

Dim temp2 as variant
For Each Temp In Files
With myDiag
.Show
End With
Select Case Temp
Case "DEU"
For Each Temp2 In Washes
MsgBox CurrentDb.TableDefs(Temp2 & "_" & temp).Name
Next element
Case "DDE"
End Select
Next element
__________________
"Never stop learning, because life never stops teaching"

Last edited by arnelgp; 11-26-2015 at 06:55 AM.
arnelgp is offline   Reply With Quote
Old 11-26-2015, 06:55 AM   #3
prabha_friend
Prabhakaran Karuppaih
 
Join Date: Mar 2009
Location: Chennai
Posts: 360
Thanks: 64
Thanked 3 Times in 3 Posts
prabha_friend is an unknown quantity at this point
Send a message via Yahoo to prabha_friend
Re: Aren't the elements of a variant, variants too?

Quote:
Originally Posted by arnelgp View Post
should be:

For each Temp In Files
Hi Arnel,
Thanks to your reply. Please see in the code that there is one more loop needed to looped through an another array. Is there any possibility that I can use the elements of the temp (instead of the temp itself) to successfully loop both of the arrays and read the currently element's value of both them?

Thanks to you again Arnel. I want to know why I am not able to assign a value in a looping scenario though it is a variant.

__________________
Believe in God. See in People. Be a God. Believe in People.
prabha_friend is offline   Reply With Quote
Old 11-26-2015, 07:01 AM   #4
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,568
Thanks: 68
Thanked 2,744 Times in 2,629 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Aren't the elements of a variant, variants too?

see my post, i added another variant variable temp2.
i don't have the answer to your question, its just the way it is.
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 11-26-2015, 08:09 AM   #5
gemma-the-husky
Super Moderator
 
gemma-the-husky's Avatar
 
Join Date: Sep 2006
Location: UK
Posts: 13,791
Thanks: 55
Thanked 1,027 Times in 993 Posts
gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all
Re: Aren't the elements of a variant, variants too?

ignore. more complex than I thought.
__________________
Dave (Male!)
Gemma was my dog

if a poster helps you, please click the scales at the bottom left of this posting, or use the thanks button alongside.

Last edited by gemma-the-husky; 11-26-2015 at 08:18 AM.
gemma-the-husky is offline   Reply With Quote
Old 11-27-2015, 01:07 PM   #6
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 14,570
Thanks: 92
Thanked 1,682 Times in 1,560 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Aren't the elements of a variant, variants too?

Perhaps I am being a bit more dense than normal but I don't see where there is any syntax suggesting that Temp is a structure and therefore, I don't see why the two explicit arrays would be associated intimately with the Temp variant or variant array.

I HAVE used arrays and structures in both simple combinations: arrays containing structures and structures comprised of multiple arrays. What I see doesn't look at all like what I used in the other cases.

What were you originally trying to do?
__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Old 12-01-2015, 04:04 AM   #7
prabha_friend
Prabhakaran Karuppaih
 
Join Date: Mar 2009
Location: Chennai
Posts: 360
Thanks: 64
Thanked 3 Times in 3 Posts
prabha_friend is an unknown quantity at this point
Send a message via Yahoo to prabha_friend
Thumbs up Re: Aren't the elements of a variant, variants too?

Done this way:
Code:
Public Function RefreshLinks()
'Function to Relink the Files
Dim vrtFiles As Variant 'Types of Files
Dim vrtWashes As Variant    'Types of Washes
Dim vrtTemp As Variant  'Temporaray Variable
Dim myDiag As FileDialog    'Dialog box to select File/Folder
 vrtFiles = Array("DEU", "DDE")
vrtWashes = Array("Business Wash", "Corporate Wash", "Coupon Wash", "Dividend Wash")
vrtTemp = Array(0, 0)
Set myDiag = FileDialog(msoFileDialogFilePicker)
 Do While vrtTemp(0) <= UBound(vrtFiles) 'Delete the Linked the Table and Relink it
    
    With myDiag
        .Title = "Select the Appropiate File for the Table : " & vrtFiles(vrtTemp(0))
        .Show
    End With
    
    Select Case vrtFiles(vrtTemp(0))
        Case "DEU"
            Do While vrtTemp(1) <= UBound(vrtWashes)
                DoCmd.DeleteObject acTable, vrtWashes(vrtTemp(1)) & "_DEU"
                Call LinkTheTable(vrtWashes(vrtTemp(1)) & "_DEU", myDiag.SelectedItems(1))
                vrtTemp(1) = vrtTemp(1) + 1
            Loop
        Case "DDE"
            DoCmd.DeleteObject acTable, "DDE"
            Call LinkTheTable("DDE", myDiag.SelectedItems(1))
    End Select
    
    vrtTemp(0) = vrtTemp(0) + 1
 Loop
End Function
Sorry for a very late reply


__________________
Believe in God. See in People. Be a God. Believe in People.
prabha_friend is offline   Reply With Quote
Reply

Tags
array , can't assign to this , compile error , loop , variant

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Survey with common elements and form specific elements RobinL Tables 0 01-16-2012 01:58 AM
Labeling Elements Numerical Elements in a Combo Box Twkehr2 Forms 3 07-02-2009 11:36 AM
Help with params and variants?? jedcomyn Modules & VBA 1 06-17-2004 03:50 AM
comparing dates against dates held in variants sametch Modules & VBA 26 09-21-2003 07:13 AM




All times are GMT -8. The time now is 01:15 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World