PDA

View Full Version : Looking for Visual Basic help


Hostile
May 7th, 2004, 02:57 AM
And I just pray someone here actually knows it.

Ok, I've got a project called prjTodsTyres. I've got a frmMain which then leads to frmJobs. This can be seen in This Picture (http://another-world.org.uk/hos/forms.jpg). From here you can view Tod's many tyre jobs. This part works. So next you click on Create Invoice, which opens frmInvoice.

Now, this is where it gets crappy. I've included all of the frmInvoice code at the bottom of the page so anyone with experience might go through it and point my errors out, much appreciated.

When frmInvoice loads, it gathers the incorrect information. As you'll see in that picture I linked to, i've picked to make an invoice for Blue Fox, yet Ritual's details come up. This is the code I used to theoretically produce Blue Fox details:

datInv.RecordSource = "SELECT FROM Customers WHERE CompanyName = frmJobs.txtCustomer "

I've double-triple-quadruple-checked those names. datInv points to the correct database, and does indeed select data from Customers>CompanyName. Only problem is it always picks the first file's data, Ritual. This happens for every customer.

I also have a problem with the discount code, but i'll ask about that after I get help fixing this problem.

P.S. Haste is appreciated, since the deadline is today. Thanks so much for any consideration you put towards this.

Dim TyreCost As Integer

Private Sub Command1_Click()
frmInvoice.Hide
End Sub

Private Sub Command2_Click()
frmInvoiceCustom.Show
End Sub

Private Sub Form_Activate()

' Label Stuff
lblInvoiceNo.Caption = "Invoice #:" & frmJobs.txtJobID.Text
'TXT Stuff

'txtCompany.Text = frmJobs.txtCustomer.Text
'txtTyreNo.Caption = frmJobs.txtTyreNo.Text
'txtTyresSold.Caption = frmJobs.cboTyreType.Text

' complicated Tyre Type IF Statement

If frmJobs.cboTyreType.Text = "155/80S13" Then
TyreCost = 36
Else
If frmJobs.cboTyreType.Text = "165/80S13" Then
TyreCost = 39
Else
If frmJobs.cboTyreType.Text = "155/80S14" Then
TyreCost = 58
Else
If frmJobs.cboTyreType.Text = "165/80S14" Then
TyreCost = 64
End If
End If
End If
End If

txtCostEach.Caption = "£" & TyreCost

' More complicated TXT Stuff
lblTotalCost.Caption = "£" & TyreCost * txtTyreNo.Caption

If frmInvoiceCustom.Check1.Value = True Then
lblDiscounted.Caption = lblTotalCost.Caption * 0.95
Else
lblDiscounted.Caption = "N/A"
End If

' Data Stuff


datInv.RecordSource = "SELECT FROM Customers WHERE CompanyName = frmJobs.txtCustomer "
datInvJobs.RecordSource = "SELECT FROM Jobs WHERE JobID = frmJobs.txtJobID "

End Sub
Private Sub Form_Load()
txtDate.Text = Date
'datInv.RecordSource = "SELECT * FROM Customers WHERE CompanyName = " & "'" & frmJobs.cboCustomer & "'" & ""
'datInv.Refresh
'datInvJobs.RecordSource = "SELECT * FROM Jobs WHERE JobID = " & "'" & frmJobs.txtJobID & "'" & ""
frmStock.Show
frmStock.Hide
'frmInvoiceCustom.Show
'frmInvoiceCustom.Hide
End Sub

TomSluder
May 7th, 2004, 12:53 PM
datInv.RecordSource = "SELECT FROM Customers WHERE CompanyName = frmJobs.txtCustomer "
datInvJobs.RecordSource = "SELECT FROM Jobs WHERE JobID = frmJobs.txtJobID "

End Sub
Private Sub Form_Load()
txtDate.Text = Date
'datInv.RecordSource = "SELECT * FROM Customers WHERE CompanyName = " & "'" & frmJobs.cboCustomer & "'" & ""
'datInv.Refresh
'datInvJobs.RecordSource = "SELECT * FROM Jobs WHERE JobID = " & "'" & frmJobs.txtJobID & "'" & ""
frmStock.Show
frmStock.Hide
'frmInvoiceCustom.Show
'frmInvoiceCustom.Hide
End Sub

Perhaps it's the fact that you're using "SELECT FROM Customers" and "Select FROM Jobs" instead of "Select * FROM Customers" and "Select * FROM Jobs"

If you know anything about SQL you should be able to see the difference. Let me know if that doesn't work and I'll do a more in-depth code review.

--Tom