Click here to Skip to main content
16,013,465 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionCrystal Report on Basis of Dataset having multiple tables Pin
Syed Ali Raza25-May-07 2:26
Syed Ali Raza25-May-07 2:26 
AnswerRe: Crystal Report on Basis of Dataset having multiple tables Pin
Rupesh Kumar Swami25-May-07 2:52
Rupesh Kumar Swami25-May-07 2:52 
GeneralRe: Crystal Report on Basis of Dataset having multiple tables Pin
Syed Ali Raza25-May-07 2:56
Syed Ali Raza25-May-07 2:56 
GeneralRe: Crystal Report on Basis of Dataset having multiple tables Pin
Syed Ali Raza25-May-07 3:33
Syed Ali Raza25-May-07 3:33 
GeneralRe: Crystal Report on Basis of Dataset having multiple tables Pin
Rupesh Kumar Swami25-May-07 4:24
Rupesh Kumar Swami25-May-07 4:24 
QuestionAutomate Microsoft Word From VB6 Pin
Carter Langley25-May-07 2:15
Carter Langley25-May-07 2:15 
AnswerRe: Automate Microsoft Word From VB6 Pin
Johan Hakkesteegt28-May-07 2:34
Johan Hakkesteegt28-May-07 2:34 
GeneralRe: Automate Microsoft Word From VB6 Pin
Carter Langley28-May-07 2:45
Carter Langley28-May-07 2:45 
Dim strCountry As String
Dim strCustomer As String
Dim strManufacturer As String
Dim strBitMake As String
Dim strBitSize As String
Dim strMotorType As String
Dim strBlockNumber As String
Dim strSectionNumber As String
Dim strDepthIn As String
Dim strDepthOut As String
Dim strFootageDrilled As String
Dim strFormation As String
Dim strFormation1 As String
Dim strSearch As String
Dim strRst As String
Dim strPunctuation As String
Dim lngLen As Integer
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTable As Word.Table
Dim oPara1 As Word.Paragraph
Dim oRng As Word.Range
Dim oShape As Word.InlineShape
Dim oChart As Object
Dim Pos As Double

If cboCountry.Text <> "" Then
strCountry = cboCountry.Text
strRst = "SELECT Countryid FROM Country WHERE Country LIKE " & "'" & strCountry & "'"
Rst.Open strRst, Cnn, adOpenDynamic, adLockOptimistic
strCountry = "BitRun.CountryID = " & Rst.Fields("Countryid").Value & " AND "
Rst.Close
strRst = ""
Else
strCountry = ""
End If

If cboCustomer.Text <> "" Then
strCustomer = cboCustomer.Text
strRst = "SELECT Customerid FROM Customer WHERE Customer LIKE " & "'" & strCustomer & "'"
Rst.Open strRst, Cnn, adOpenDynamic, adLockOptimistic
strCustomer = "BitRun.customerid = " & Rst.Fields("Customerid").Value & " AND "
Rst.Close
strRst = ""
Else
strCustomer = ""
End If

If cboManufacturer.Text <> "" Then
strManufacturer = cboManufacturer.Text
strRst = "SELECT BitManufacturerid FROM Bit_Manufacturer WHERE Manufacturer LIKE " & "'" & strManufacturer & "'"
Rst.Open strRst, Cnn, adOpenDynamic, adLockOptimistic
strManufacturer = "BitRun.BitManufacturerid = " & Rst.Fields("BitManufacturerid").Value & " AND "
Rst.Close
strRst = ""
Else
strManufacturer = ""
End If

If cboBitSize.Text <> "" Then
strBitSize = "BitRun.Size = '" & cboBitSize.Text & "' AND "
Else
strBitSize = ""
End If

If cboMotorType.Text <> "" Then
strMotorType = cboMotorType.Text
strRst = "SELECT MotorID FROM Motor WHERE MotorType LIKE " & "'" & strMotorType & "'"
Rst.Open strRst, Cnn, adOpenDynamic, adLockOptimistic
strMotorType = "BitRun.MotorID= " & Rst.Fields("MotorID").Value & " AND "
Rst.Close
strRst = ""
Else
strMotorType = ""
End If

If cboBlockNumber.Text <> "" Then
strBlockNumber = "BitRun.BlockNumber = '" & cboBlockNumber.Text & "' AND "
Else
strBlockNumber = ""
End If

If cboSectionNumber.Text <> "" Then
strSectionNumber = "BitRun.SectionNumber = '" & cboSectionNumber.Text & "' AND "
Else
strSectionNumber = ""
End If

If txtDepthIn.Text <> "" Then
strDepthIn = "BitRun.MDIn" & txtDepthIn.Text & " AND "
Else
strDepthIn = ""
End If

If txtDepthOut.Text <> "" Then
strDepthOut = "BitRun.MDOut" & txtDepthOut.Text & " AND "
Else
strDepthOut = ""
End If

If txtFootageDrilled.Text <> "" Then
strFootageDrilled = "BitRun.FootageDrilled" & txtFootageDrilled.Text & " AND "
Else
strFootageDrilled = ""
End If

If txtFormations.Text <> "" Then
strPunctuation = ","
strFormation1 = Replace(txtFormations.Text, strPunctuation, " OR BitRun.Formation = ")
strFormation = "BitRun.Formation = " & strFormation1
Else
strFormation = ""
End If

strSearch = "SELECT * FROM BitRun WHERE BitRun.Performance NOT LIKE 'Poor' AND " & _
strCountry & strCustomer & strManufacturer & _
strBitMake & strBitSize & strMotorType & strBlockNumber & strSectionNumber & _
strDepthIn & strDepthOut & strFootageDrilled & strFormation

If Right(strSearch, 5) = " AND " Then
lngLen = Len(strSearch) - 5
strSearch = Left$(strSearch, lngLen)
strSearch = strSearch & ";"
Else
strSearch = strSearch & ";"
End If

Set rstSearch = New ADODB.Recordset
rstSearch.Open "SELECT * FROM SQLSearchTextString", Cnn, adOpenDynamic, adLockOptimistic
If Not rstSearch.EOF Then
rstSearch.Delete adAffectCurrent
End If

rstSearch.AddNew
rstSearch.Fields("sqlsearch") = strSearch
rstSearch.Update
rstSearch.Close

'Start Word and open the document template.
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add
oDoc.PageSetup.Orientation = wdOrientLandscape
oDoc.PageSetup.LeftMargin = 10
oDoc.PageSetup.RightMargin = 10
oDoc.PageSetup.TopMargin = 30

'Insert a paragraph at the beginning of the document.
Set oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "Diamant Drilling Services Run Report"
oPara1.Range.Font.Name = "Arial Rounded MT Bold"
oPara1.Range.Font.Color = wdColorBlue
oPara1.Range.Font.Size = 28
oPara1.Range.Font.Bold = False
oPara1.Range.InsertParagraphAfter
oPara1.Range.InsertParagraphAfter

Set oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = "QDC"
oPara1.Range.Font.Name = "Arial"
oPara1.Range.Font.Color = wdColorBlue
oPara1.Range.Font.Size = 8
oPara1.Range.Font.Bold = True


OK, there you have it, my probably totally unprofessional attempt at coding, but it works so far so i must say i am quite pleased with myself.
my problem is with the range object i think. i need to have more than one word on a line and i just cant seem to do this. the first line is to have the headers and the following lines are to have the information organised under the relevent headers.

vb.net is not an option, i only have vb6 and not even the msdn help files so battling is putting it mildly.
GeneralRe: Automate Microsoft Word From VB6 Pin
Johan Hakkesteegt28-May-07 3:38
Johan Hakkesteegt28-May-07 3:38 
Questioninternetwritefile in vb.net Pin
psiva198425-May-07 2:03
psiva198425-May-07 2:03 
AnswerRe: internetwritefile in vb.net Pin
Dave Kreskowiak25-May-07 3:28
mveDave Kreskowiak25-May-07 3:28 
Questionquery related to vb Pin
Ms. Shaheen25-May-07 1:59
Ms. Shaheen25-May-07 1:59 
AnswerRe: query related to vb Pin
Carter Langley25-May-07 2:21
Carter Langley25-May-07 2:21 
Questionquery related to vb Pin
Ms. Shaheen25-May-07 1:58
Ms. Shaheen25-May-07 1:58 
AnswerRe: query related to vb Pin
Kschuler25-May-07 7:47
Kschuler25-May-07 7:47 
Questionhow to add state property Pin
d_smit25-May-07 0:41
d_smit25-May-07 0:41 
AnswerRe: how to add state property Pin
Dave Kreskowiak25-May-07 3:21
mveDave Kreskowiak25-May-07 3:21 
Questionpassword protection [modified] Pin
Sonia Gupta25-May-07 0:17
Sonia Gupta25-May-07 0:17 
AnswerRe: password protection Pin
Dave Kreskowiak25-May-07 3:16
mveDave Kreskowiak25-May-07 3:16 
QuestionBackup Dbs in vb.net Pin
gitasnr24-May-07 23:54
gitasnr24-May-07 23:54 
AnswerRe: Backup Dbs in vb.net Pin
Colin Angus Mackay25-May-07 0:07
Colin Angus Mackay25-May-07 0:07 
GeneralRe: Backup Dbs in vb.net Pin
gitasnr25-May-07 0:19
gitasnr25-May-07 0:19 
GeneralRe: Backup Dbs in vb.net Pin
Dave Kreskowiak25-May-07 3:10
mveDave Kreskowiak25-May-07 3:10 
GeneralRe: Backup Dbs in vb.net Pin
Colin Angus Mackay25-May-07 8:03
Colin Angus Mackay25-May-07 8:03 
GeneralRe: Backup Dbs in vb.net Pin
Dave Kreskowiak25-May-07 11:56
mveDave Kreskowiak25-May-07 11:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.