Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 8th, 2008, 05:52 AM
Spand Spand is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 12 Spand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 21 sec
Reputation Power: 0
Question Some challenging VBA coding for Forms

Hi guys!
I have 3 queries here, answer whatever u have time for
Say I have a form with the following fields

a. cbo Pipe class
b.cbo Component Type
c. txtComponent Id
c.cbo size
d.txt schedule
e.txt mesc

I have 20 pipe classes, each has 36 components. (all the classes hav similar structure n same components, only their corresponding numerical values differ)

1. If comp <> "BROB" And comp <> "RECB" And comp <> "REEB" And comp <> "TERB"….. Then
Me.cboSize2.Visible = False
End if

Can I write that statement in a better way? I want to know what’s the VB syntax for something like this

If comp IN(“BROB”,”RECB”…….) then
-------
End IF

2. I need to populate combo box Size with values from table class1_mescList if pipe class=1, But only those sizes for which component Id= txtComponent ID.

I have to use table class2_mescList if pipe class=2…. Etc, u get the picture!

How can I write a query for this? I don’t think trying to give specifications in Row source will be the best approach (as I said I have 30 classes!)

3. This is how I find value for txtSchedule

Private Sub txtSchedule1_GotFocus()
Dim class
class = cboPipeClass.Value
Dim size
size = cboSize1.Value
Dim schedule
Select Case class
Case "11440"
schedule = DLookup("Schedule", "11440_ScheduleList", "Size=" & [size])
Case "11441"
schedule = DLookup("Schedule", "11441_ScheduleList", "Size=" & [size])
End Select

txtSchedule.Value = schedule

End Sub

As u can see, the only difference between when pipe class=11440 and when its =11441 is that in the first case, we perform the DLookUp fn on 11440_ScheduleList table and in the second case on 11441_ScheduleList table.
Is there an option other that writing 30 cases?? can do something to say
(classNo)_ScheduleList in the DLookup function.
Its kinda important cause the we might add more classes later on, in which case whoever is maintaining the DB will have to come back to the code and add another case statement.

Reply With Quote
  #2  
Old May 8th, 2008, 10:46 AM
rpeare rpeare is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 467 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 7 m 47 sec
Reputation Power: 117
For the first part you can do the following:

if Instr(Comp, "BROBRECBREEBTERB") > 0 then
Me.cboSize2.visible = false
else
Me.cboSize2.visible = true
endif

where the string in the instr function would contain all the unique strings that you DO NOT want to have cbosize2 available for.

For the second part I think you're may be making it a bit more complicated than necessary. Is the structure (STRUCTURE not CONTENT) for your tables

Class1_mescList
Class2_mescList
...
Class30_mescList

the same? If they are you can have all of these tables combined into 1 table and just have a class identifier included then when you create your combo box you can base it on only the class that is relevant.

Part 3 would also follow this model where you should only have to pick the class along with your current information to be able to get what you want.

Take a close look at the structure of your class tables and schedule tables, if they are nearly identical or are identical in structure you are going to save yourself a lot of aggravation and time if you can combine them into one table and put in an additional identifier for the class.
Comments on this post
AOG123 agrees!
__________________
----------------
If we've helped you and you have solved your problem please post that it's been resolved so we know! The suspense kills me!

Reply With Quote
  #3  
Old May 9th, 2008, 01:38 AM
Spand Spand is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 12 Spand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 21 sec
Reputation Power: 0
Question

Thanks rpeare!

hmm i tried using
If InStr(comp, "BROBRECBREEB") > 0 Then

instead of

If comp <> "BROB" And comp <> "RECB" And comp <> "REEB" then

but its not working! that peice of IF block is not doing anything after replacement.

For my 2nd and 3rd queries, you are right- the structures are exactly the same. what you suggested would definetly mak the coding part of it a lot easier. And it would solve the problem of adding additional classes later on.
The reason i chose to have seperate tables is that, each one allready has about 400 entries. I didn't want 400* 20 (the no of classes) =8000 entries in one table!
Wouldn't that make searching the table a lot slower? and better chance of it being corrupted by the user?

Reply With Quote
  #4  
Old May 9th, 2008, 08:14 AM
rpeare rpeare is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 467 rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level)rpeare User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 7 m 47 sec
Reputation Power: 117
For part 1 you're going to have to post your code, I can't guess at what went wrong without seeing what you did. remember to encapsulate all of your code in [ code ] [ /code ] markers (take out the spaces within the square brackets to make it work correctly.

Secondly, having 20 separate tables for storing identical data is a lot more problematic than storing them on one table. One table regardless of how much it contains, is no less or no more susceptible to corruption than 20 tables. As far as making your database slower I seriously doubt you will even notice the difference in time because everything you're going to run is going to be based on a class and instead of looking up from an individual table you'll be looking up a chunk of records one time per query (or should be) so it shouldn't really make that much difference in human time. The only thing you have to be wary of and program for is that a user can't accidentally modify one class while working on another.

For my 2nd and 3rd queries, you are right- the structures are exactly the same. what you suggested would definetly mak the coding part of it a lot easier. And it would solve the problem of adding additional classes later on.
The reason i chose to have seperate tables is that, each one allready has about 400 entries. I didn't want 400* 20 (the no of classes) =8000 entries in one table!
Wouldn't that make searching the table a lot slower? and better chance of it being corrupted by the user?
Comments on this post
don94403 agrees: Exactly right. A table with 8,000 records is a teensy tiny table to Access!

Reply With Quote
  #5  
Old May 12th, 2008, 01:40 AM
Spand Spand is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 12 Spand User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 43 m 21 sec
Reputation Power: 0
Thumbs up

hi rpeare,

oo i was making a silly mistake with that first problem.. its works now!

i took your advice and restructured my tables.. you guys were right, that does make life simpler!
thanks a lot!

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Some challenging VBA coding for Forms


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway