473,626 Members | 3,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data Environment help please

16 New Member
i need to view salary payslip (data report) based on that particular month and year.

in Data Environment sql :

SELECT[emp_id], [emp_name], [emp_position], [emp_bs], [month_paid], [year_paid], [total_addition], [gross_pay], [total_deduction], [total_pay] FROM salary WHERE month_paid = ? and year_paid = ?

parameter is monthler

parameter is yearler


in vb code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim intMonth As Integer
  3. Dim intYear As Integer
  4.  
  5. ' is a combo box that select month
  6.  
  7. If cboMonth.ListIndex = 0 Then
  8.     intMonth = 1
  9. ElseIf cboMonth.ListIndex = 1 Then
  10.     intMonth = 2
  11. ElseIf cboMonth.ListIndex = 2 Then
  12.     intMonth = 3
  13. ElseIf cboMonth.ListIndex = 3 Then
  14.     intMonth = 4
  15. ElseIf cboMonth.ListIndex = 4 Then
  16.     intMonth = 5
  17. ElseIf cboMonth.ListIndex = 5 Then
  18.     intMonth = 6
  19. ElseIf cboMonth.ListIndex = 6 Then
  20.     intMonth = 7
  21. ElseIf cboMonth.ListIndex = 7 Then
  22.     intMonth = 8
  23. ElseIf cboMonth.ListIndex = 8 Then
  24.     intMonth = 9
  25. ElseIf cboMonth.ListIndex = 9 Then
  26.     intMonth = 10
  27. ElseIf cboMonth.ListIndex = 10 Then
  28.     intMonth = 11
  29. ElseIf cboMonth.ListIndex = 11 Then
  30.     intMonth = 12
  31. End If
  32.  
  33.  is a combo box that select year
  34.  
  35. If cboYear.ListIndex = 0 Then
  36.     intYear = 2007
  37. ElseIf cboYear.ListIndex = 1 Then
  38.     intYear = 2008
  39. ElseIf cboYear.ListIndex = 2 Then
  40.     intYear = 2009
  41. ElseIf cboYear.ListIndex = 3 Then
  42.     intYear = 2010
  43. ElseIf cboYear.ListIndex = 4 Then
  44.     intYear = 2011
  45. End If
  46.  
  47.  
  48.  
  49. ' how should i pass a value to a Data Environment sql query ?
  50. or got other way to do ?
  51. ' i need view that month and year that i have selected. 
  52. 'P_Payslip.Show
  53.  
  54.  
  55.  
  56.  
Apr 3 '07 #1
10 2993
Dököll
2,364 Recognized Expert Top Contributor
i need to view salary payslip (data report) based on that particular month and year.

in Data Environment sql :

SELECT[emp_id], [emp_name], [emp_position], [emp_bs], [month_paid], [year_paid], [total_addition], [gross_pay], [total_deduction], [total_pay] FROM salary WHERE month_paid = ? and year_paid = ?

parameter is monthler

parameter is yearler


in vb code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim intMonth As Integer
  3. Dim intYear As Integer
  4.  
  5. ' is a combo box that select month
  6.  
  7. If cboMonth.ListIndex = 0 Then
  8.     intMonth = 1
  9. ElseIf cboMonth.ListIndex = 1 Then
  10.     intMonth = 2
  11. ElseIf cboMonth.ListIndex = 2 Then
  12.     intMonth = 3
  13. ElseIf cboMonth.ListIndex = 3 Then
  14.     intMonth = 4
  15. ElseIf cboMonth.ListIndex = 4 Then
  16.     intMonth = 5
  17. ElseIf cboMonth.ListIndex = 5 Then
  18.     intMonth = 6
  19. ElseIf cboMonth.ListIndex = 6 Then
  20.     intMonth = 7
  21. ElseIf cboMonth.ListIndex = 7 Then
  22.     intMonth = 8
  23. ElseIf cboMonth.ListIndex = 8 Then
  24.     intMonth = 9
  25. ElseIf cboMonth.ListIndex = 9 Then
  26.     intMonth = 10
  27. ElseIf cboMonth.ListIndex = 10 Then
  28.     intMonth = 11
  29. ElseIf cboMonth.ListIndex = 11 Then
  30.     intMonth = 12
  31. End If
  32.  
  33.  is a combo box that select year
  34.  
  35. If cboYear.ListIndex = 0 Then
  36.     intYear = 2007
  37. ElseIf cboYear.ListIndex = 1 Then
  38.     intYear = 2008
  39. ElseIf cboYear.ListIndex = 2 Then
  40.     intYear = 2009
  41. ElseIf cboYear.ListIndex = 3 Then
  42.     intYear = 2010
  43. ElseIf cboYear.ListIndex = 4 Then
  44.     intYear = 2011
  45. End If
  46.  
  47.  
  48.  
  49. ' how should i pass a value to a Data Environment sql query ?
  50. or got other way to do ?
  51. ' i need view that month and year that i have selected. 
  52. 'P_Payslip.Show
  53.  
  54.  
  55.  
  56.  
Just posted the below, gillian3114, greetings...

Give it a whirl. I also posted another that deals with Data Environment. Will find it for you:

http://www.google.com/search?q=Data.. .ie7&rlz=1I7SUN A

+++++++++++++++ +++++++

Please search a bit deeper here if this is no help. I added "Data Report without Data Environment " to Google to fetch info included there.

Good luck with the project!

Dököll
Apr 3 '07 #2
cmrhema
375 Contributor
i need to view salary payslip (data report) based on that particular month and year.

in Data Environment sql :

SELECT[emp_id], [emp_name], [emp_position], [emp_bs], [month_paid], [year_paid], [total_addition], [gross_pay], [total_deduction], [total_pay] FROM salary WHERE month_paid = ? and year_paid = ?

parameter is monthler

parameter is yearler


in vb code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim intMonth As Integer
  3. Dim intYear As Integer
  4.  
  5. ' is a combo box that select month
  6.  
  7. If cboMonth.ListIndex = 0 Then
  8.     intMonth = 1
  9. ElseIf cboMonth.ListIndex = 1 Then
  10.     intMonth = 2
  11. ElseIf cboMonth.ListIndex = 2 Then
  12.     intMonth = 3
  13. ElseIf cboMonth.ListIndex = 3 Then
  14.     intMonth = 4
  15. ElseIf cboMonth.ListIndex = 4 Then
  16.     intMonth = 5
  17. ElseIf cboMonth.ListIndex = 5 Then
  18.     intMonth = 6
  19. ElseIf cboMonth.ListIndex = 6 Then
  20.     intMonth = 7
  21. ElseIf cboMonth.ListIndex = 7 Then
  22.     intMonth = 8
  23. ElseIf cboMonth.ListIndex = 8 Then
  24.     intMonth = 9
  25. ElseIf cboMonth.ListIndex = 9 Then
  26.     intMonth = 10
  27. ElseIf cboMonth.ListIndex = 10 Then
  28.     intMonth = 11
  29. ElseIf cboMonth.ListIndex = 11 Then
  30.     intMonth = 12
  31. End If
  32.  
  33.  is a combo box that select year
  34.  
  35. If cboYear.ListIndex = 0 Then
  36.     intYear = 2007
  37. ElseIf cboYear.ListIndex = 1 Then
  38.     intYear = 2008
  39. ElseIf cboYear.ListIndex = 2 Then
  40.     intYear = 2009
  41. ElseIf cboYear.ListIndex = 3 Then
  42.     intYear = 2010
  43. ElseIf cboYear.ListIndex = 4 Then
  44.     intYear = 2011
  45. End If
  46.  
  47.  
  48.  
  49. ' how should i pass a value to a Data Environment sql query ?
  50. or got other way to do ?
  51. ' i need view that month and year that i have selected. 
  52. 'P_Payslip.Show
  53.  
  54.  
  55.  
  56.  
I have used datareports BUT WITHOUT data environment, and I pass the query in form code itself
You must be having a control where you will be prompting the user to print report
Try out the below code in that control

Dim db_file As String
Dim Mycon1 As New ADODB.Connectio n
' Get the data.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "emp.mdb"
' Open a connection.
Mycon1.Connecti onString = _
"Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
Me.Refresh
Mycon1.Open
Set m1 = Mycon1.Execute( "SELECT emp_id, emp_name, emp_position, emp_bs, month_paid, year_paid, total_addition, gross_pay, total_deduction , total_pay FROM salary WHERE month_paid = " & intMonth & " and year_paid =" & intYear & "", , adCmdText)
' Connect the Recordset to the DataReport.
Set DataReport1.Dat aSource = m1
DataReport1.Win dowState = vbMaximized
DataReport1.Sho w vbModal
DataReport1.Cap tion = "Invoice"
m1.Close
Mycon1.Close
Mycon1.Open
Set Mycon1 = Nothing
End If


This code works for me
Good Luck
Apr 3 '07 #3
Dököll
2,364 Recognized Expert Top Contributor
I have used datareports BUT WITHOUT data environment, and I pass the query in form code itself
You must be having a control where you will be prompting the user to print report
Try out the below code in that control

Dim db_file As String
Dim Mycon1 As New ADODB.Connectio n
' Get the data.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "emp.mdb"
' Open a connection.
Mycon1.Connecti onString = _
"Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
Me.Refresh
Mycon1.Open
Set m1 = Mycon1.Execute( "SELECT emp_id, emp_name, emp_position, emp_bs, month_paid, year_paid, total_addition, gross_pay, total_deduction , total_pay FROM salary WHERE month_paid = " & intMonth & " and year_paid =" & intYear & "", , adCmdText)
' Connect the Recordset to the DataReport.
Set DataReport1.Dat aSource = m1
DataReport1.Win dowState = vbMaximized
DataReport1.Sho w vbModal
DataReport1.Cap tion = "Invoice"
m1.Close
Mycon1.Close
Mycon1.Open
Set Mycon1 = Nothing
End If


This code works for me
Good Luck
Good job, cmrhema!

Here is the link I was looking for, gillian3114. You can query your database and furnish a report:

http://www.dreamincode.net/forums/showtopic13544.htm

Give above time to load, snapshots included. Continue asking questions, we'll ge there...

Take cmrhema also, see how that works for you.
Apr 3 '07 #4
vijaydiwakar
579 Contributor
I have used datareports BUT WITHOUT data environment, and I pass the query in form code itself
You must be having a control where you will be prompting the user to print report
Try out the below code in that control

Dim db_file As String
Dim Mycon1 As New ADODB.Connectio n
' Get the data.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "emp.mdb"
' Open a connection.
Mycon1.Connecti onString = _
"Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
Me.Refresh
Mycon1.Open
Set m1 = Mycon1.Execute( "SELECT emp_id, emp_name, emp_position, emp_bs, month_paid, year_paid, total_addition, gross_pay, total_deduction , total_pay FROM salary WHERE month_paid = " & intMonth & " and year_paid =" & intYear & "", , adCmdText)
' Connect the Recordset to the DataReport.
Set DataReport1.Dat aSource = m1
DataReport1.Win dowState = vbMaximized
DataReport1.Sho w vbModal
DataReport1.Cap tion = "Invoice"
m1.Close
Mycon1.Close
Mycon1.Open
Set Mycon1 = Nothing
End If


This code works for me
Good Luck
Nice answer so far
keep it up
Apr 3 '07 #5
gillian3114
16 New Member
Error: Object Requiered.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim intMonth As Integer
  3. Dim intYear As Integer
  4.  
  5. If cboMonth.ListIndex = 0 Then
  6.     intMonth = 1
  7. ElseIf cboMonth.ListIndex = 1 Then
  8.     intMonth = 2
  9. ElseIf cboMonth.ListIndex = 2 Then
  10.     intMonth = 3
  11. ElseIf cboMonth.ListIndex = 3 Then
  12.     intMonth = 4
  13. ElseIf cboMonth.ListIndex = 4 Then
  14.     intMonth = 5
  15. ElseIf cboMonth.ListIndex = 5 Then
  16.     intMonth = 6
  17. ElseIf cboMonth.ListIndex = 6 Then
  18.     intMonth = 7
  19. ElseIf cboMonth.ListIndex = 7 Then
  20.     intMonth = 8
  21. ElseIf cboMonth.ListIndex = 8 Then
  22.     intMonth = 9
  23. ElseIf cboMonth.ListIndex = 9 Then
  24.     intMonth = 10
  25. ElseIf cboMonth.ListIndex = 10 Then
  26.     intMonth = 11
  27. ElseIf cboMonth.ListIndex = 11 Then
  28.     intMonth = 12
  29. End If
  30.  
  31. If cboYear.ListIndex = 0 Then
  32.     intYear = 2007
  33. ElseIf cboYear.ListIndex = 1 Then
  34.     intYear = 2008
  35. ElseIf cboYear.ListIndex = 2 Then
  36.     intYear = 2009
  37. ElseIf cboYear.ListIndex = 3 Then
  38.     intYear = 2010
  39. ElseIf cboYear.ListIndex = 4 Then
  40.     intYear = 2011
  41. End If
  42.  
  43. Dim Mycon1 As New ADODB.Connection
  44. Dim m1 As New ADODB.Recordset
  45. Dim strCNString As String
  46.  
  47. strCNString = "Data Source=" & App.Path & "\PayrollBakeryDB.mdb"
  48. Mycon1.Provider = "Microsoft Jet 4.0 OLE DB Provider"
  49. Mycon1.ConnectionString = strCNString
  50. Mycon1.Open
  51.  
  52.     Set m1 = Mycon1.Execute("SELECT emp_id, emp_name, emp_position, emp_bs, month_paid, year_paid, total_addition, gross_pay, total_deduction, total_pay FROM salary ", , adCmdText)
  53. ' Connect the Recordset to the DataReport.
  54.  
  55.     Set DataReport1.DataSource = m1 ' error: object required
  56.  
  57.  
  58.     DataReport1.WindowState = vbMaximized
  59.     DataReport1.Show vbModal
  60.     DataReport1.Caption = "Invoice"
  61.     m1.Close
  62.     Mycon1.Close
  63.     Mycon1.Open
  64.     Set Mycon1 = Nothing
  65.  
  66.  
Apr 3 '07 #6
vijaydiwakar
579 Contributor
Error: Object Requiered.

[code]
pls sho the place where u got the error
Apr 3 '07 #7
gillian3114
16 New Member
error occur at:


Set DataReport1.Dat aSource = m1
Apr 3 '07 #8
cmrhema
375 Contributor
error occur at:


Set DataReport1.Dat aSource = m1
Sorry Gillian for the trouble
Fogot to tell you that one should Declare m1 intially
Dim m1 As New ADODB.Recordset
Apr 4 '07 #9
Arvindkumar
3 New Member
Hello All

I have the similar problem in data environment. Though the code works well to set the data source with report.

How can I show the data in Reports. Say I have text1 as a text box in report and I want to display the data in the textbox.

Also I want to display all the records that matching the criteria :
say
select * from emp where sal >5000

Please help I am in trouble

Thanks
May 12 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
3414
by: Jack | last post by:
Hi, I am trying to test a sql statement in Access which gives me the error as stated in the heading. The sql statement is built as a part of asp login verification, where the userid and password are input in login screen. The password in the database is a number field. I am writing the dynamic sql statement as follows below. I believe I am going wrong in the password section of the code. I appreciate any help. Thanks. Regards.
2
1771
by: Bob Alston | last post by:
Anyone out there successfully deployed Data Access Pages, on a server they do not control, using RDS in a 3-tier environment? If so I would like to hear about your success. From my reading, RDS is not widely available on commercial servers due to security issues advised by Microsoft (see prior posts). I have done it successfully in a two tier environment - which (according to Microsoft) is where the page is on a server, but the access...
6
1774
by: Jon Davis | last post by:
I like the drag-and-drop accessibility of dragging a table to a Web Forms designer and seeing a SqlDataAdapter automatically created for me.. being able to create a DataSet from that is fun and exciting, because now with this schema based data outline Visual Studio provides me with a typed class for managing data complete with Intellisense menus exposing my own field names as C# object properties ... cool .. Anyway, I have a problem. I...
1
1922
by: EO | last post by:
I am trying to use the MSFT data access application block on 3 machines. Machine 1: Sandbox environment; I installed the application block with the msi. The Sqlhelper class compiles & runs great! (Also the SqlhelperParameterCache class; I'll refer to them collectively as the SqlHelper class.) I'm using unmodified application block code in all cases. Machine 2: Development environment, different project
5
3267
by: sjl | last post by:
I've got an .aspx webform for searching my database. It basically takes user input and passes it as a parm into a stored proc to search a table. The results are returned in a SQLDataReader and bound to a datagrid on the same page. It works 90% of the time as expected. However, for some unknown reason, I randomly get the error below. The HttpException says there is an 'Invalid_Viewstate'. Ok, but why? I'm posting back to the same page. If...
10
1659
by: Doug Bell | last post by:
Hi, I have an application that has a "Data Access Class" and "User Interface Class". It is for receiving Purchase Order data from one system and pushing processed transactions to another system. The system generally works quite well. Currently the User interface calls for a refresh of data every 15 minutes (selectable) and the Data Access Class connects to the DB and retrieves the
5
15712
by: Arno | last post by:
reposted with the right microsoft managed newsgroup ID: Sorry for the inconvinience Hi, I've written a class for client-socket connection, but I get a lot of times the error message "Unable to read data from the transport connection" when restart reading the stream with socket.BeginRead in the Sub SocketIncomingMsg. I'm debugging now for weeks, but I can't detect where it's
0
1199
by: kowndinya | last post by:
I have created a small program with Data Environment. database is MS Access. It is working fine on my computer where VB 6 was Installed. I want to use this program on different machines where there is no Visual basic. I am not able to see the data in the form . All fields are empty. Created my connection/ command using Data Environment. droped these data command on to main form (i have only one form). Data entry form was created...
2
2047
by: manugm1987 | last post by:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style type="text/css"><!-- span.cls_002{font-family:Times,serif;font-size:12px;color:rgb(0,0,0);font-weight:normal;font-style:normal} div.cls_002{font-family:Times,serif;font-size:12px;color:rgb(0,0,0);font-weight:normal;font-style:normal} span.cls_004{font-family:Times,serif;font-size:11px;color:rgb(0,0,0);font-weight:normal;font-style:normal}
0
8202
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8641
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.