Results 1 to 7 of 7
  1. #1
    alaric01 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    17

    Help - How to Get textbox value from datasheet subform

    Hi

    i have a main form that contains customer data. On the main form i have a datasheet subform that displays the history of transaction for each customers.

    the datasheet only displays 3 fields from the table. what i want to do is to create a button that opens a popup form that displays the transaction details (all the fields) based on the invoice no from the datasheet subform.

    the main form is frm_main_customer
    and the subform is frm_main_transaction

    and the textbox in the datasheet subform from which i want to retrieve the data is called txt_invoice_no

    what i did was create a button that opens the transaction detail form lets say it is called frm_transaction. in the frm_transaction onLoad event i create a vba code to filter the data based on the invoice_on on the datasheet subform.

    the code was like

    me.filter = invoice_no = "Forms!frm_main_customer.txt_invoice_no.value
    me.filteron = true



    what happened was when i run the application and click the detail button it is asking for a parameter which is the invoice_no.

    if i put the invoice no in the parameter box it will popup the form with the correct data. however i want it to display the data without asking for the parameter.

    i've used the code for other forms (but not a datasheet subform) and it worked perfectly.

    i've also tried to change the code to:

    me.filter = invoice_no = "Forms!frm_main_transaction.txt_invoice_no.val ue"
    me.filteron = true

    still cannot make it work.

    any idea??

    thx

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    me.filter = "invoice_no = '" & Forms!frm_main_transaction.txt_invoice_no.value & "'"
    me.filteron = true

    don't miss the (').

    I am not sure if you need to specify frm_main_customer, if above doesn't work, try it:
    me.filter = "invoice_no = '" & forms!frm_main_customer!frm_main_transaction.txt_i nvoice_no.value & "'"
    me.filteron = true

  3. #3
    alaric01 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    17
    weeked00 thx for your reply

    i've tried both ways.for the first one

    me.filter = "invoice_no = '" & Forms!frm_main_transaction.txt_invoice_no.value & "'"
    me.filteron = true

    i've got a runtime error 2450 saying that Microsoft Access can't find the form frm_main_transaction referred to in a macro expression or visual basic code.

    as for the second one

    me.filter = "invoice_no = '" & forms!frm_main_customer!frm_main_transaction.txt_i nvoice_no.value & "'"
    me.filteron = true

    i've got a run time error 438 saying that Object doesn't support this property or method..

    any other ideas?

  4. #4
    alaric01 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    17
    i've tried to change the default view to single form and still have the same problem. so i guess the problem is not the datasheet but the subform. how can i can get a textbox value from a subform?

    still figuring this out..

  5. #5
    alaric01 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    17

    problem solved

    solved the problem,.the problem was the syntax, found out that a subform is just another control on the main form.

    so i change the code to

    Me.Filter = "invoice_no = Forms!frm_main_customer!frm_main_transaction.Form. txt_invoice_no.Value "

    Me.FilterOn = True

    and oh yeah i did not use the ('), didn't work when i use it..

    finally can have a good night sleep...

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Good night.

    Is invoice_no a number? I was thinking it is a string.

  7. #7
    alaric01 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    17
    invoice_no is an auto_increment number

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Automatically update datasheet
    By tammiep in forum Forms
    Replies: 1
    Last Post: 08-17-2010, 04:43 PM
  2. Datasheet and Code
    By dbprogman in forum Forms
    Replies: 7
    Last Post: 07-26-2010, 07:39 AM
  3. Replies: 1
    Last Post: 05-29-2010, 02:39 AM
  4. Datasheet View
    By Evgeny in forum Programming
    Replies: 6
    Last Post: 04-28-2010, 10:17 AM
  5. Replies: 3
    Last Post: 02-10-2010, 07:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums