Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Access

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 07-08-2010, 03:48 AM
shital shital is offline Windows XP Access 2007 (version 12.0)
Novice
 
Join Date: Jul 2010
Posts: 3
shital is on a distinguished road
Default write stored procedure with 'if else'

hi,
Hi all,

I want to write a stored procedure in MS Access 2007, which will have 'If else condition'

example:
if (@flag=0)
Select * from Table1;
else if (@flag=1)
Select * from Table2;
else
Select * from Table3;

How can i write the Stored Procedure in MS Access 2007, which will give me the above output?

Thanks in advance....
Reply With Quote
  #2  
Old 07-08-2010, 04:12 AM
maximus's Avatar
maximus maximus is offline Windows 7 Access 2010 (version 14.0)
Wizard
 
Join Date: Aug 2009
Location: India
Posts: 804
Blog Entries: 1
maximus is on a distinguished road
Default

the quetion that I would like to ask here is what are you trying achieve:

here is a simple example:

I have a text Box Text1 based on its value i will change the row source of a Combobox in the form Combo1. The code is attached to a command button:

Dim strSQL as String

If Me.Text1=1 then
strSQl="Select * From Table1"
elseid Me.Text1=2 then
strSQL="Select * From Table2"
Else
strSQL="Select * From Table 3"
End if

Me.Combo1.RowSource=strSQL
__________________
How to Mark a thead solved:
http://www.accessforums.net/forum-su...lved-1828.html

Contact
for Solutions to your database problems and at affordable rates
silverback_bats@yahoo.co.in
Reply With Quote
  #3  
Old 07-08-2010, 04:26 AM
shital shital is offline Windows XP Access 2007 (version 12.0)
Novice
 
Join Date: Jul 2010
Posts: 3
shital is on a distinguished road
Default

hi,
in above query 'flag' will be assigned runtime in c#.net application and Access is my backend.
As per the 'flag' value i want to fetch data from different table.
Reply With Quote
Reply

Bookmarks

Tags
access 2007, if else, stored procedure

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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating Stored Procedure in Access 2007 shraddha Access 5 08-03-2010 07:43 AM
Using adp with sql backend. Need to filter stored procedure fillerup Queries 0 05-12-2010 07:41 AM
Pass image parameter to stored procedure Kencao Programming 3 04-28-2010 09:51 PM
Passing variable values to Stored Procedure rodrigopcnet Access 1 04-14-2010 08:35 AM
Newbie question, can't create stored procedure bbpalmer Access 1 11-17-2009 03:55 AM


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


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.