»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 10-22-2003, 12:27 PM   #1 (permalink)
Registered User
 
Join Date: Nov 2001
Posts: 170
Turnip12 is on a distinguished road
Access ACTextBox/Arrays ???

OK,I got the copying fields thing to work, and now I'm just trying to make my code less embarrassing. I have a ridiculous number of lines of code for copying info from form to form. Basically I set the focus to the form, check to see if there's a value, if there is copy it into a variable, and then set the focus the the other forms textbox, copy the value from the variable into the textbox, and then repeat for each textbox. It works, but it's ugly. So, I thought about two other methods to cut down on the code.

1. Put the names of the text boxes into an array, and then increment through the array doing the same as above.

2. Use ctl.ControlType = acTextBox since everything will be coming from, and going to textboxes.

So I'm thinking with either, I'll be able to cut out the repeat part. Just use some kind of For Loop, function. or something along those lines, and then do it once, incrementing through for the array. I'm curious as to which of the above (or maybe something else I don't know of) would be better to use. Any suggestions or recommendations? And if #2 would be better, could someone give me a quick rundown on how to use it. I've searched around the web and came up with examples, but I'm still having trouble getting it to work right.

Turnip12 is offline   Reply With Quote
Old 10-22-2003, 01:35 PM   #2 (permalink)
Registered User
 
Join Date: Nov 2001
Posts: 170
Turnip12 is on a distinguished road
ok, I'm actually not getting either method to work, but now I'm pretty sure the crtl.ControlType method isn't possible for what I have in mind. The code for my array is going to be something along the lines of

Dim Test(5) As String
Dim Index As Integer

Test(0) = "txtBldg"
Test(1) = "txtSerial"
Test(2) = "txtAccount"
Test(3) = "txtName"
Test(4) = "txtDept"

For Index = 0 To 5 Step 1
strTest = Test(Index)
strTest.SetFocus
If strTest.Text <> "" Then
strValue = strTest.Text
Else
strValue = Null
End If
Me.sfrmSubTotal!strTest.SetFocus
Me.sfrmSubTotal!strTest.Text = strValue
Next Index

But of course it doesn't work, I'm getting a compile error: Invalid qualifier. Any input would be greatly appreciated.
Turnip12 is offline   Reply With Quote
Old 10-22-2003, 05:13 PM   #3 (permalink)
Registered User
 
Join Date: Oct 2001
Location: TOO close to Wash DC
Posts: 7,956
vass0922 is on a distinguished road
Try starting from 1. Unfortunately VB/VBA/VBS and its other technologies like WMI/ADSI are not very standard on where to start the array index.

btw, you don't have to put step 1 .. its implied

The best way to do this is to create a control array, but not sure if you can do that in POS access.

You can try, by selecting one of your text boxes, and copying and pasting onto the same form. It should prompt you if you want to create a control array IF its possilbe.

If that doesn't work, try putting
Set strTest = Test(Index)
as you're copying the textbox object ... not just its value
__________________
<< Insert exceedingly large and overly verbose message of how 1337 you are here including full specs of every vehicle you've ever driven and PC you've owned >>
vass0922 is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 01:12 AM.