Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2004
    Posts
    10

    Unanswered: Where do I put this code?

    I am going through a book on VB Databases. I am creating a find form to find a customer by their name and have it enter the selection to my main customer form. Anyway, I have it all set up except one thing - the book says to place the following code in the calling form:

    frmFind.recordSource = [drive letter]:\[database location]
    frmFind.addCaption = "All Records"

    But it doesn't tell me where to put it in the calling form. I know this is basic but I am truly just learning. Thanks in advance for any help!

  2. #2
    Join Date
    Dec 2004
    Location
    Laguna, Philippines
    Posts
    147
    Can u further explain your question and put more details on the code.
    Give me a place to code and i shall move the earth!

  3. #3
    Join Date
    Dec 2004
    Posts
    10
    I have a frmCustomer and a frmFind. frmFind displays all the names in my customer database based on what a user types in a textbox in the form. frmFind is suppose to be self contained so I can used it on multiple forms by changing only a little code.

    frmCustomer is the "calling" form. My frmFind is called by a command button called cmdFind on frmCUstomer. The book says to enter the following code in the calling form (frmCustomer) but doesn't say where to enter it.

    frmFind.recordSource = [drive letter]:\[database location]
    frmFind.addCaption = "All Records"

    The book explains that my calling form will automatically tell my frmFind the database location based on the code above before frmFind even loads. DOes that make sense?

  4. #4
    Join Date
    Dec 2004
    Location
    Laguna, Philippines
    Posts
    147
    i still dont get what is frmFind.recordsource and frmFind.addCaption? a control? procedure? function? etc.

    but based on your last statement placed your code to the click event of your command button..

    'Try this...
    Private Sub cmdFind_Click()
    frmFind.recordSource = [drive letter]:\[database location]
    frmFind.addCaption = "All Records"

    End Sub
    Give me a place to code and i shall move the earth!

  5. #5
    Join Date
    Dec 2004
    Posts
    10
    Maybe this will help. I set a property in my frmFind

    Public Property Let recordSource(ByVal sNewValue As String)
    dtaFind.recordSource = sNewValue
    End Property

    Public Property Let addCaption(ByVal sNewValue As String)
    lblWhichTable = sNewValue
    End Property

    Right after I do this, the book tells me to enter

    frmFind.recordSource = [drive letter]:\[database location]
    frmFind.addCaption = "All Records"

    in the calling form (frmCustomer)

  6. #6
    Join Date
    Dec 2004
    Location
    Laguna, Philippines
    Posts
    147
    show me your codes in click method of your cmdFind.
    Last edited by coleone; 01-11-05 at 02:50.
    Give me a place to code and i shall move the earth!

  7. #7
    Join Date
    Dec 2004
    Posts
    10
    Case cmdFind '-- find a specific record
    Dim iReturn As Integer
    gFindString = ""

    With frmFind
    .addCaption = "Type Customer Name to Find"
    .recordSource = "SELECT ContactFirstName FROM tblCustomerInfo ORDER BY ContactFirstName"
    .Show vbModal
    End With

    If (Len(gFindString) > 0) Then
    With Data1.Recordset
    .FindFirst "Name = '" & gFindString & "' "
    If (.NoMatch) Then
    iReturn = MsgBox("Customer Name " & gFindString & _
    " was not found.", vbCritical, "Customers")
    Else
    iReturn = MsgBox("Customer Name " & gFindString & _
    " was retrieved.", vbInformation, "Customers")
    End If
    End With
    End If

    I apologize for my ignorance. I am getting an error 3061 - too few parameters. Expected 1. I found an article saying that the record source could be wrong???
    Thank you for your help!

  8. #8
    Join Date
    Dec 2004
    Location
    Laguna, Philippines
    Posts
    147
    Send me the two forms. frmCustomer and frmFind and sample db some lines are confusing...
    Give me a place to code and i shall move the earth!

Posting Permissions

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