Results 1 to 10 of 10
  1. #1
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102

    lost data in one fied after performing a search

    I have a form frmMember, it has a search button that performs a complex search of fields. after performing my search my [BaseDues] field shows #Name? BaseDues is set by a CBO in the field above.
    It works correctly except after the search...

    Here is the Code for the Search Button:

    Private Sub cmdSearchForm_Click()
    On Error GoTo Err_cmdSearchForm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmSearch"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_cmdSearchForm_Click:


    Exit Sub

    Err_cmdSearchForm_Click:
    MsgBox Err.Description
    Resume Exit_cmdSearchForm_Click

    End Sub

    frmSearch Row Source is:

    "CompanyName";"PhysicalAddress";"MailingAddress";" ContactFirstName";"ContactLastName";"ContactPhone" ;"BusinessPhone";"Fax";"Email";"WebSite";"Business Type";"KeyWords"

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    lots of confusing comments here. Your search button code does nothing other than open a form called frmSearch and passes an empty variable as a WHERE condition. There is no search performed by the button click. Also, forms don't have row sources - they have record sources. Anyway, the error usually means a reference you are using cannot be resolved. Try stepping though the code that exectues after the button click to see if you can detect which line generates the error. Or is the error showing up in a form control?

  3. #3
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    it is not actually giving an error. The data in the BaseDues is no being displayed as it does in the standard form view and scrolling through the records with the navigation at the bottom. instead of giving the value from [tblMemberType].[BaseDues] in currency (ei: $100.00) in the form view, it displays #Name?. while viewing the form selected by the search.
    Also the [frmSearch].[cboSearchField] is what the above mentioned "Row Source" is from. it designates what criteria I can select my search from...
    I am thinking I do not have something set to source the BaseDues from, but I just don't know where to look...

  4. #4
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    Question:

    I believe it is in these lines of code not having the [tblMemberType] included in the Record source???

    Form_frmMember.RecordSource = "select * from tblMember where " & GCriteria
    Form_frmMember.Caption = "Members (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"

    How do I add the tblMemberType to the TblMember?
    Would I simply add code to the end of the first line:

    Form_frmMember.RecordSource = "select * from tblMember where " & GCriteria And "Select * from tblMemberType where " & GCriteria?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    How are tblMemberType and tblMember related? What are the PK/FK fields? Build query that joins these tables.

    SELECT tblMemberType.*, tblMember.* FROM tblMemberType RIGHT JOIN tblMember ON tblMemberType.ID=tblMember.TypeID;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    tblMember PK = ID;
    tblMemberType PK = ID;
    [tblMemberType].[ID] related to [tblMember].[MemberTypeID] join type 1 (both table are equal.)

    Current code:
    Form_frmMember.RecordSource = "select * from tblMember where " & GCriteria

    Your code suggestion:
    SELECT tblMemberType.*, tblMember.* FROM tblMemberType RIGHT JOIN tblMember ON tblMemberType.ID=tblMember.TypeID;

    How do I add this part of the code at the end???:
    where " & GCriteria

  7. #7
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    You've posted info that suggests [BaseDues] is a form control that contains an expression that can't be resolved. If it contains an expression, post it and maybe explain a bit about it.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    SELECT tblMemberType.*, tblMember.* FROM tblMemberType RIGHT JOIN tblMember ON tblMemberType.ID=tblMember.TypeID WHERE " & GCriteria & ";"

    Is this what you are trying to do http://www.allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102

    Red face

    I am integrating this search system into my DB. It work exactly the way I was looking for.FormSearch2.zip
    I will try your suggeste code and respond later...
    Thank you again for your help. I have grown in access leaps and bounds through your time and assistance.

  10. #10
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    Here is the final code I used to resolve the issue. I had to slightly adjust the code but it worked wonderfully.

    Thank You.

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

Similar Threads

  1. Replies: 5
    Last Post: 12-08-2014, 01:13 PM
  2. Lost data and access new tables
    By chazcoral2 in forum Security
    Replies: 18
    Last Post: 02-26-2013, 04:21 PM
  3. Replies: 5
    Last Post: 07-26-2012, 09:42 PM
  4. Replies: 12
    Last Post: 03-22-2012, 02:48 AM
  5. Performing count in VBA
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 08-21-2010, 07:41 PM

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