Go Back   Access World Forums > Microsoft Access Discussion > Access Web

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 10-09-2019, 05:11 PM   #1
Sonya_G
Newly Registered User
 
Join Date: Oct 2019
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Sonya_G is on a distinguished road
sqL or Query?!!

Okay programmers this Is whats up:

I am biuldiing a diabetic program, and the main area of topic is the Combo box. I have it coded so that the (list) insulin_nation is either Canada, USA, from there somethings hide and others show. On the click event of insulin_nation it pulls all the names from patient ad loads them in name_Combo (full name). What I want it to is select all the names from patient based on the choice from the list box (insulin_nation), whos country in the patients table must match. I tried putting a filter on, it works but not eiffecently. So my two other choices would be SQL, or query. I am thinking SQL. Here is what I have so far:
Private Sub nation_Combo_AfterUpdate()
Dim nation As Variant
nation = nation_Combo
If nation = "Canada" Then
Me.name_Combo
SELECT name_Combo, country
from patient
where country = "Canada"


insulin_Combo.Visible = False
CAN_insulin_Combo.Visible = True
Zcell.Visible = True
ratio.Visible = False
corr_ratio.Visible = False

Else

mysql>SELECT full_name, country
from patient
where country = "USA"

insulin_Combo.Visible = True
CAN_insulin_Combo.Visible = False
Zcell.Visible = False
ratio.Visible = True
corr_ratio.Visible = True

End If
End Sub
diabetic.zip

Sonya_G is offline   Reply With Quote
Old 10-09-2019, 05:24 PM   #2
theDBguy
Im here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 4,566
Thanks: 50
Thanked 1,047 Times in 1,028 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: sqL or Query?!!

Hi. Is there any way you can post a small copy of your db with test data and only the form you're having problems with?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 10-09-2019, 05:25 PM   #3
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 932
Thanks: 10
Thanked 189 Times in 179 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: sqL or Query?!!

I'm confused by your post.
- At one point it seems like you have a combo for nation but then you describe it as a list box.
- Then you mention a click event but post code for after update event.
- A query is based on SQL language so they are one and the same. Maybe you mean a sql statement in vba?
- you cannot use > in this context
"mysql>SELECT full_name, country"; even if you could it would make no sense.
- you would not set the value of a combo or list box as in
"Me.name_Combo SELECT name_Combo" you would set its rowsource property.
- sql statements in code must be enclosed in quotes. You have none, save for quotes around the criteria. You must enclose the entire statements in double quotes and the text type criteria has to be delimited too. Typically this is done via singles ' or doubling up on double quotes. I find using singles to be far simpler.

EDIT - forgot to ask you to post code within code tags (# on forum toolbar) with indentation to make it easier to read.

__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)

Last edited by Micron; 10-09-2019 at 05:34 PM.
Micron is offline   Reply With Quote
Old 10-09-2019, 11:32 PM   #4
Sonya_G
Newly Registered User
 
Join Date: Oct 2019
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Sonya_G is on a distinguished road
Re: sqL or Query?!!

here you go, I just started. The form I am working with is USA calc1.
Attached Files
File Type: zip diabetic.zip (89.0 KB, 3 views)
Sonya_G is offline   Reply With Quote
Old 10-09-2019, 11:51 PM   #5
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,385
Thanks: 68
Thanked 2,698 Times in 2,583 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: sqL or Query?!!

instead of hiding/unhiding textbox, which may make your form have gap like teeth, you make them Enable or Disabled.

also you can make separate form for each country, put it on Tab control and switch Page when the country combo changes, see this sample.

I remove the Tab from the Pages.
Attached Files
File Type: zip diabetes.zip (46.2 KB, 7 views)
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 10-13-2019, 12:21 PM   #6
Sonya_G
Newly Registered User
 
Join Date: Oct 2019
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Sonya_G is on a distinguished road
Re: sqL or Query?!!

I went back in and followed your direction, rebuilding and recoding but I have some problems. On he main calc my combo and button do not how up in form view, only design view. Next I am having troubles figuring out the tab control # so that Ii can code it. Help!?
Attached Files
File Type: zip dia-doc1.zip (89.1 KB, 2 views)
Sonya_G is offline   Reply With Quote
Old 10-13-2019, 01:13 PM   #7
June7
AWF VIP
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,266
Thanks: 0
Thanked 532 Times in 528 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: sqL or Query?!!

Need to move combobox and button into Form Header or Detail section, not Page Header. Page Header/Footer only displays when printing, not screen display.

There is no Tab control on [main calc]. Subforms are just sitting on top of each other, not on Pages of Tab control. With this arrangement, code would be:
Code:
Private Sub nation_Combo_AfterUpdate()
Me.CANpatients.Visible = Nz(Me.nation_Combo, "") = "Canada"
Me.USApatients.Visible = Nz(Me.nation_Combo, "") = "USA"
End Sub
Set both subform containers as Visible No in [main calc] design view. Remove [blanc] subform.

__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by June7; 10-13-2019 at 01:46 PM.
June7 is offline   Reply With Quote
Old 10-13-2019, 01:42 PM   #8
Sonya_G
Newly Registered User
 
Join Date: Oct 2019
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Sonya_G is on a distinguished road
Re: sqL or Query?!!

Thanx for the tip, it makes sense why it doesn't work.

Sonya_G is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 12:17 AM.


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