Results 1 to 7 of 7
  1. #1
    sovereign is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    30

    Form pulling data from two locations and view data

    Hi,

    I am relatively new working in VBA and SQL,

    I have created a form called "Frmfleetchecksheet"

    1st thing: I have a search box that points to "qryFrmfleetchecksheet" on update that then populates 3 fields by using record source and control source

    At the moment it has multiple fields around 20 that I have code that inserts these into a table "fleet_checksheet"

    i then wanted to link the fields to this table so i can pull previous checksheets. (this will be done via a button from another form)

    but if i add both tables into "qryFrmfleetchecksheet" i get Recordset is not updateable

    I have checked.. data entry to yes, recordset type on qry is Dynaset, unique values is set to no.

    I think i also need the qry to show all from both tables is the possible?



    not sure if its best to use some code to populate the 3 fields on a 'search' button click for example from the table and insert into the form rather than using a qry.

    Any help would be much appreciated and thanks in advanced

    Regards

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Even if it is a dynaset , SOME queries, due to joining 2 tables, cannot update.
    That join prevents update.
    usu because they don't have a true 1 to many relation.

  3. #3
    sovereign is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    30
    i see, so if i wanted to pull data direct from the table "fleet"

    Code:
    Private Sub Command913_Click()
    
    Dim Reg As String
    Dim Fireg As String
    Dim Fimake As String
    Dim Fimodel As String
    
    Reg = Me.txtFregSearch
    
    Fireg = DLookup([Freg], [Fleet], [Reg])
    Fimake = DLookup([fmake], [Fleet], [Reg])
    Fimodel = DLookup([Fmodel], [Fleet], [Reg])
    
    Me.txtFReg.Value = Fireg
    Me.txtFmake.Value = Fimake
    Me.txtFmodel.Value = Fimodel
    
    End Sub
    I have got this but says it cannot find the Field 'Freg' but this is what it is called

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    First off, is the Field in question, that Access cannot find, actually Freg, as you currently have, or is it Freq? If the latter, you'll need to correct all instances of it in the code.

    Also, your syntax for the DLookups isn't correct. The syntax varies depending on the DataType of the Field in the Where Clause. For your first example it would be:

    If Where Field is Numeric

    Code:
    Fireg = DLookup("Freg", "Fleet", "[MatchingFieldInTable] = " & Me.txtFregSearch)

    If Where Field is Text

    Code:
    Fireg = DLookup("Freg", "Fleet", "[MatchingFieldInTable] = '" & Me.txtFregSearch & "'")

    where MatchingFieldInTable is the Field in the Fleet Table that needs to match Me.txtFregSearch.

    Note that the Field to be returned has to be enclosed in Quotation Marks.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    sovereign is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    30
    Thank you for your detailed response it is much appreciated!

    will have a play with it now. it should be "Freg"

  6. #6
    sovereign is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2015
    Posts
    30
    it worked perfectly! Thank you so much

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!



    Welcome to AFN!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 5
    Last Post: 12-27-2012, 02:54 PM
  2. Replies: 1
    Last Post: 07-16-2012, 02:10 PM
  3. View data in the form
    By Naweed in forum Forms
    Replies: 2
    Last Post: 06-28-2012, 09:32 AM
  4. Data not visible in Form view
    By CASmith in forum Forms
    Replies: 8
    Last Post: 12-23-2011, 04:02 PM
  5. Combining Data from 3 locations into one database
    By jparker1954 in forum Access
    Replies: 5
    Last Post: 08-30-2011, 06:42 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