Results 1 to 11 of 11

Thread: [RESOLVED] [Urgent] Problem in linking my CarRegNo to my database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Resolved [RESOLVED] [Urgent] Problem in linking my CarRegNo to my database

    The problem arise is in the invoice form where i used this coding to retrieve data from my database. In the coding below, the combo1,text is retrived from an invoice table.

    VB Code:
    1. Private Sub Form_Load()
    2.     Set Inv = New Class3 ' The text field and combo text is link to my invoice database
    3.     Set Text1.DataSource = Inv
    4.     Text1.DataField = "InvoiceID"
    5.     Set Text2.DataSource = Inv
    6.         Text2.DataField = "DateRent"
    7.     Set Text3.DataSource = Inv
    8.     Text3.DataField = "DateReturn"
    9.     Set combo1.DataSource = Inv
    10.     combo1.DataField = "CustID"

    combo1 is the CarRegNO in MS access and is the foreign key in invoice table and also a primary key in car details. The car details in linked 1 - M relations to the invoice table.

    VB Code:
    1. Private Sub Combo1_Click() '<--- this combo1 is open from a car details table
    2. Call connectDB
    3.     If Combo1.Text <> "Select Car Reg No" Then
    4.         sql = "SELECT DISTINCT * FROM CarDetails WHERE CarRegNo='" & Combo1.Text & "'"
    5.         rs.Open sql, cn, adOpenStatic, adLockOptimistic, adCmdText

    The same combo1 text, but they are open in different tables using ADODB connection. How can i form a relationship between them?
    Last edited by macky^^; Feb 10th, 2006 at 12:29 AM.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: Problem in linking my CarRegNo to my database

    Pls give a try to my query
    Thanks.

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Problem in linking my CarRegNo to my database

    I don't really get what's your problem, would you elucidate? Are you looking for JOIN?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: Problem in linking my CarRegNo to my database

    Quote Originally Posted by dee-u
    I don't really get what's your problem, would you elucidate? Are you looking for JOIN?
    maybe it's a join problem.
    Cos i used different query commands to open different tables. For example, I used 1 query to open custID in customer table and 1 used 1 query to open carregno in cardetails. However, in my main form, i used 1 query to open my invoice table, which consist of custiD and carregno as the foreign key.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [Urgent] Problem in linking my CarRegNo to my database

    What do you mean by "form a relationship"?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: [Urgent] Problem in linking my CarRegNo to my database

    Quote Originally Posted by Hack
    What do you mean by "form a relationship"?
    Sorry to trouble you every night

    sorry, i mean the link my custID from customer table with custid from invoice table and the link my carregno from cardetails table with carregno from invoice table

    hence, i think i need to do a join sql ....

  7. #7
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641

    Re: [Urgent] Problem in linking my CarRegNo to my database

    Is this what you mean (see attached for sample app)
    Attached Files Attached Files
    Martin J Wallace (Slaine)

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: [Urgent] Problem in linking my CarRegNo to my database

    hi Slaine,

    Thanks for that sample file, but i'm looking for a join sql sample.

  9. #9
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641

    Re: [Urgent] Problem in linking my CarRegNo to my database

    An example of a join would be:

    Code:
    SELECT Car.*, Invoice.* FROM Invoice LEFT JOIN Car ON Invoice.CarReg = Car.CarReg WHERE InvoiceId = *somenumber*
    But that won't magically link your combo box to your invoice - if that's what you are wanting.
    Martin J Wallace (Slaine)

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    365

    Re: [Urgent] Problem in linking my CarRegNo to my database

    yes, how can i link the combo to my invoice?

  11. #11
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641

    Re: [Urgent] Problem in linking my CarRegNo to my database

    See my previous code.

    You load the combo-box with the possible values from the database, then when you load the invoice you set the selected item in the combo-box to what ever is specified in the fetched invoice record.
    Martin J Wallace (Slaine)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width