|
|
i had generated a report from a query in access (ie using the query as a datasource), and that worked fine. However, now i want to run the report based on the query in the database and 2 values (ie between 2 dates) in textboxes so i have hardcoded the following SQL statement behind the command button to generate the report. However, i do not know what to do from here - the SQL statement will be a datasource and datamember for what - the data environment? the command? the report? Thanking you!
SELECT DISTINCT Client.Company, OrderGenerate.OrderNumber, Sum(OrderDetail.Price) AS SumOfPrice
FROM (Client INNER JOIN OrderGenerate ON Client.ClientCode=OrderGenerate.ClientCode) INNER JOIN OrderDetail ON OrderGenerate.OrderNumber=OrderDetail.OrderNo
WHERE Date Between ' " & txtDateFrom.Text & "' and ' " & txtDateTo.Text & "'
GROUP BY Client.Company, OrderGenerate.OrderNumber
|
|
|
|
|
Hi,
I found the following code in the MSDN Articles. The title of the article is "Customizing Microsoft Internet Explorer 5.0". I don't know why it isn't working. It asks if I want to create the button but then it does nothing. Could you help me please?
Thank you
' AddButtonIE.vbs
' Adds a custom button to the Internet Explorer 5.0 toolbar
' -----------------------------------------------------------------------
rc = MsgBox("Would you like to add a new button to the toolbar?", vbYesNo)
if rc=vbNo Then WScript.Quit' The registry path where you add your new entries.
' If your registry doesn't contain a Shell node, it'll be silently created
REG_HKLM_IE50_BASE = "HKLM\Software\Microsoft\Internet Explorer\Extensions"' Adds a new key (needs a newly created GUID)
REG_HKLM_IE50_GUID = REG_HKLM_IE50_BASE & "\{10954C80-4F0F-11d3-B17C-00C0DFE39736}\"' Creates the required values
Set shell = WScript.CreateObject("WScript.Shell")
shell.RegWrite REG_HKLM_IE50_GUID & "ButtonText", "Run Script", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "MenuText", "Run Script", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "MenuStatusBar", "Run Script", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Clsid", "{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Default Visible", "Yes", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Icon", "C:\Program Files\Home.ro\icon1.ico", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "HotIcon", "C:\Program Files\Home.ro\icon2.ico", "REG_SZ"
shell.RegWrite REG_HKLM_IE50_GUID & "Exec", "C:\Program Files\Home.ro\myprg.vbs", "REG_SZ"
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Sorry! My bad. It works fine.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
how to get the singel cell name in the sheet.
i = 1, j=2
Dim str As String
str = Cells(i, j).Name
I excepted str = "B1" but I got run time error...
Can anyone tell me why?
thanks
|
|
|
|
|
"B1" is not a cells name, that's it's position. You can give names to cells or a range of cells in Excel for the purpose of easing calculation. For example, if a cell has a value of 2.142.... and you name it PI, then in your formulas,you can refer to it as PI like so:
=B2 + PI which would make more sense.
So, the cell.name propert returns the name of the cell, not the position. If it doesn't have a name, you get a run-time error
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Thank you SMC,
Can you please tell me how to get the position of the particular cell. and can you also check my following incorrect code please. I'm trying to wait for the user to close the excel application after they done with whatever they have to do to the excel file. where am i getting wrong and how to fix it.
<br />
Dim idProc As Long<br />
Dim hProc As Long<br />
idProc = VBA.Shell("Excel", vbMaximizedFocus)<br />
hProc = OpenProcess(PROCESS_ALL_ACCESS, False, idProc)<br />
If hProc Then<br />
Do While WaitForSingleObject(hProc, 100) = WAIT_TIMEOUT<br />
<br />
DoEvents<br />
Loop<br />
CloseHandle hProc<br />
End If<br />
Thank you.
|
|
|
|
|
Hello Gurus...
I want the exiting excel file to open it, format it and print it.
opening and formating part I have ( mostly) done ... but to printing giving me problems.. when the file get print, there are lots of empty pages because of the last cell.
let's say, the sheet contain only two cells that has some data. the first cell is A1 and the last cell is z130 and there are no data in the cells between first and last cells.
So when I call PrintOut method it prints all the empty pages.
I'm trying to set the print area for the excel sheet because I don't want to print empty pages. But how can i set the print area only to print that two cells???
I tried look every cells whether if it is empty or not, if empty don't do anything but if not empty, set the range and set the printarea... the following is my code..I know it is wrong but don't know how to fix it
<br />
<br />
Function SetPrintArea(sheet As Worksheet) As Worksheet<br />
Dim r As Range<br />
Set r = sheet.UsedRange<br />
<br />
Dim newRange As Range<br />
Dim i As Integer<br />
Dim j As Integer<br />
<br />
For i = 1 To r.Rows.Count<br />
For j = 1 To r.Columns.Count<br />
If Not Cells(i, j).Value = "" Then<br />
newRange = newRange(Cells(1, i), Cells(i, j))<br />
End If<br />
Next j<br />
Next i<br />
newRange.Cells.Select<br />
sheet.PageSetup.PrintArea = Selection.Address<br />
Set SetPrintArea = sheet<br />
End Function<br />
Thanks
|
|
|
|
|
okay, I'm gonna ask the obvious question.... why are the only two cells in the sheet with the data so frikkin' far ????. That's gotta say something bout the design!
the Range object also accepts parameters in the form of a string, like so :
"A1:C5"
The above parameter would include everything from cells A1 to cells C5
But if you wanna do composite ranges, then the following string:
"A1:C5,D12:G7"
would include everything from the first string as well as everything from cell D12 to G7 and nothing in between.
I assume you could solve your problem by constructing the composite range string before hand, then pass it into the Range object
Hope that helps
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
You're damn right.. why do they do so?? Can't they just insert the information into the closer cells?? I, myself, want to know why they do that.. my job is to print that excel file..minimizing the number of pages that will print as possible.
Thank you for answer SMC, So how can i get the position of the cell?
Thank you
|
|
|
|
|
you're looping method seem to work fine.... just don't assign the cells into the range yet. Convert into the string version first, then after evrything has finished looping, assign the string into the range
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
thanks. I did the samething..
Is there anyway that I can find out whether the sheet(s) has any protection?? what if I don't know the password??
Thanks
|
|
|
|
|
Win wrote:
Is there anyway that I can find out whether the sheet(s) has any protection?? what if I don't know the password??
err..... sorry, don't know much in that area.
Notorious SMC
The difference between the almost-right word & the right word is a really large matter - it's the difference between the lightning bug and the Lightning
Mark Twain
Get your facts first, and then you can distort them as much as you please
Mark Twain
|
|
|
|
|
Hi,
I've created a .net Windows forms user control that is housed within IE. All the methods of the usercontrol work fine, but I can't get the events to filter through to IE.
I've read quite a bit about both the new event model in .net and how you need to explicitly create an interface in order to expose events to COM, however, after trying all sorts of examples, I just can't get it to work.
The code currently looks like (having removed the system generated code):
====================================================================
Option Explicit On
Option Strict On
Imports System
Imports System.Runtime.InteropServices
'Public Delegate Sub newCallDelegate(ByVal URN As Integer)
'Step 1: Define an event sink interface (ButtonEvents) to be
'implemented by the COM sink.
<guidattribute("a59b958d-b363-454b-88aa-be8626a131fb"), _
interfacetypeattribute(cominterfacetype.interfaceisidispatch)=""> _
Interface WebflowEvents
Event newCall(ByVal URN As Integer)
End Interface
'Step 2: Connect the event sink interface to a class
'by passing the namespace and event sink interface
'("EventSource.ButtonEvents, EventSrc").
<classinterface(classinterfacetype.none)> _
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
Implements WebflowEvents
Public Event newCall(ByVal URN As Integer) Implements WebflowEvents.newCall
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Firing")
RaiseEvent newCall(1234)
End Sub
End Class
=================================================================================
I REALLY need to get this to work, otherwise it's back to registration of a COM wrapper.
thanks
Graham
|
|
|
|
|
I have a complicated question, so if i dont explain it properly, or dont supply enough information, please let me know! I have 3 datacombos - 1 for product type and 2 for price Descriptions. for each combo, i wish to populate a column in the datagrid. for the first column, products are populated based on the product type chosen and prices are populated (relating to the products) based on the price descriptions chosen. This would be fine if it was only the product type and 1 of the price combos that i was using but the fact that i am using 2 price descriptions. ( i am using the same fields for comparison purposes). is there anyway i can get around this - my SQL statement isnt working( due to the fact that teh same field is being used twice). do i need to use 2 Adodcs? is it possible to populate a column of the datagrid from a SQL statement? you will see the relationship between the tables here:
Product Type: TypeCode, TypeDescription
Product: ProductCode, ProductDescription, TypeCode
Price: PriceCode, ProductCode, Price
PriceDescription: PriceCode, PriceDesc
Any help would be greatly appreciated!
|
|
|
|
|
I have a requirement in my application where in i have to dynamically add properties to the propertygrid control.
Now i am creating a class with private members having public get & set methods and then assigning the instance of the class to the selectedobject method of the propertygrid. now i want to add another property at runtime. say for example on click of a button on the form is there any way
Thanx for your help
|
|
|
|
|
I just start to work with VB.NET and i designed a form that allows me editing customer records.
The code is as follows :
Private Sub BindingFields()
con = MyConnection.GetHandler()
Mydataset = New DataSet()
MyAdapter = New SqlClient.SqlDataAdapter("select * from client", con)
MyBuilder = New SqlClient.SqlCommandBuilder(MyAdapter)
MyAdapter.Fill(Mydataset, "client")
TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_codcli"))
TextBox2.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_adrcli"))
TextBox3.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_tel1"))
TextBox4.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_nomcli"))
TextBox5.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_tel2"))
TextBox6.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_fax"))
TextBox7.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_datcre"))
TextBox10.DataBindings.Add(New System.Windows.Forms.Binding("Text", Mydataset, "client.r01_remcli"))
CheckBox1.DataBindings.Add(New System.Windows.Forms.Binding("checked", Mydataset, "client.stop_serv"))
'da.Fill(Mydataset, "Categorie")
'ComboBox1.DataSource = Mydataset
'ComboBox1.DisplayMember = "categorie.libelle"
End Sub
and the code of the AddNew button is as follows :
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
AddRecord()
End Sub
'This routine add a blank record
Private Sub AddRecord()
Mode = "A"
Try
Me.BindingContext(Mydataset, "client").EndCurrentEdit()
Me.BindingContext(Mydataset, "client").AddNew()
TextBox1.Text = Getautocode()
TextBox4.Focus()
Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
End Sub
Someone can tell me for why the fields don't become empty when i click on the addnew button .
whereas, when i disabled the line :
CheckBox1.DataBindings.Add(New System.Windows.Forms.Binding("checked", Mydataset, "client.stop_serv"))
the code works correctly.
Thank you very much.
***
|
|
|
|
|
i am trying to perform form validation on my Order Generation form. In testing for a valid quantity, i use the following if statements
ElseIf (Me.txtQuantity.Text = "") Then
MsgBox "Please enter a value for Quantity"
ElseIf Val(iQuantity) = 0 Then
MsgBox "Please enter a value for Product code"
ElseIf IsNumeric(iQuantity) = False
MsgBox "Please enter a value for Product code"
However, is doesnt seem to recognize these statements as when i dont enter a value for quantity, a message box should pop up but instead i hit a runtime error saying "type mismatch"...why is this - is there anything i can do about it? Thank you in advance!
|
|
|
|
|
I'd recommend the following:
- create a local variable based on a Trim() of the txtQuantity.Text
- check length first
- next, check for a false on IsNumeric()
- only then look for certain integer values
HTH limit further bugs
btw, which line are you getting the type mismatch from?
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
my svg article
|
|
|
|
|
Here is a basic structure of my code:
Private Sub cmdConfirm_Click()
With Adodc3.Recordset
Do Until .EOF
.MoveFirst
Call Save(iOrderNo, strCode, strDesc, iQuantity, iFullPrice)
.MoveNext
Loop
End With
Function Save(iOrderNo As Integer, strCode As String, strDesc As String, iQuantity As Integer, iFullPrice As Integer) as boolean
.....validation statements and inserts
If Val(DataGrid2.Columns("Quantity").Value) > RS("Quantity").Value Then
Call BackOrder(strCode, strDesc, iQuantity)
End If
Save = True
Function BackOrder(strCode As String, strDesc As String, iQuantity As Integer) As Boolean
....validation and inserts
BackOrder = True
To step through the code briefly, when the command button is pressed, a save function is called (for each row in the datagrid), which performs the necessary validation and saves to the database, this also calls another function - BackOrder, which enters products in a backorder if necessary. I hope the information given is sufficient, and if not, please let me know. The problem occurs when the project is run, there must be something wrong with the loop as it runs through the first row twice, upon which a bug is thrown, without ever moving onto the next row...why is this - how can i make it run through all the rows? Thank you so much - any help would be greatly appreciated!
|
|
|
|
|
mcm wrote:
Do Until .EOF
.MoveFirst
Call Save(iOrderNo, strCode, strDesc, iQuantity, iFullPrice)
.MoveNext
Loop
This code:- Moves to the first record;
- Saves the record;
- Moves to the next record;
- Goes back to the start of the loop;
- Tries to move to the first record;
- Throws an error because you have a forward-only recordset;
Change the loop to:
Do Until .Eof
' TODO: Get these values from the recordset!
Call Save(iOrderNo, strCode, strDesc, iQuantity, iFullPrice)
.MoveNext
Loop
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
hi,
i want to know whether i can use scrrun.dll in vc++(either in mfc or win32 console).if yes can anyone provide me a sample code for this?if no can u pls explain the reason?
Actually i wanted to use the ReadLine Property of scrrun.dll in vc++ either in mfc or win32 to access a text file.
shankar prasad D.R
|
|
|
|
|
I wrote a Multithread ARCNET-Driver in VC++. It receives Data Packets from the NullStackDriver. My VB6 Application opens an controls the Driver. So far so good.
The VC++ DLL is managed by serval Events (CreateEvent(), SetEvent(); ResetEvent(); WaitForSingleObject()...)
On receiving a Complete DataPacket i would like to send a additional Event ex. EVENT_RX to signalize my VB6 that it can read the Packet from the Queue and prozess it.
How can I make my VB6 Application to react on this EVENT_RX ?
Thanks for any Inputs!
|
|
|
|
|
I used to use the sourcesafe as my source control software in previose version of Visual Studio. What is used now with the .NET for source control?
If it is the Sourcesafe, what version (I found in my MSDN version 6)?
Thanks
Ilan
|
|
|
|
|
Visual Studio.NET can use VSS also. You should use 6.0c (which is the version that came with VS.NET Enterprise) since, if I remember correctly, it had some file types changes that help it work with VS.NET. 6.0c should be in the MSDN disks...
|
|
|
|
|