Results 1 to 2 of 2
  1. #1
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post
    I have a form that was formerly using bound fields but the client wanted a SAVE button. I converted to unbound fields and the save works.

    When they come back to the field and choose an Employee, I want to go to the table and populate the form. Somehow, I have goofed the syntax. HELP!

    Code:
    Private Sub Combo54_AfterUpdate()
    	' Find the record that matches the control.
    	Dim rs		  As Object
    	Dim myTable	 As DAO.Recordset
    	Set rs = Me.Recordset.Clone
    	rs.FindFirst "[EmployeeID] = '" & Me![Combo54] & "'"
    '	If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    	'=======================
    	Set myTable = CurrentDb.OpenRecordset("tbl_Employees", dbOpenDynaset, dbSeeChanges)
    			
    			myTable.FindFirst "[EmployeeID] = '" & Me.Combo54.Value & "'"
    			If myTable.NoMatch Then
    				MsgBox "No Found"
    			Else
       '  Set the recordSet
    		With myTable
    			.Edit
    			 Me.EmployeeID = [EmployeeID] ' Table items   ------------- Blows up here
    			 Me.FName = [FName]
    			 Me.LName = [LName]
    			Me.DeptLocation = [DeptLocation]
    			 Me.JobTitle.Value = [JobTitle]
    			Me.MainAddress = UCase([MainAddress])
    			 Me.MainCity = UCase([MainCity])
    			 Me.MainState = UCase([MainState])
    			 Me.MainZip = [MainZip]
    What do I need??
    Alan

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts
    [quote name='MacroAlan' post='798574' date='17-Oct-2009 12:11']I have a form that was formerly using bound fields but the client wanted a SAVE button. I converted to unbound fields and the save works.
    ...[/quote]
    My initial reaction in this situation would be to put a button they could click to save the record that didn't do anything - well maybe it would run a DoCmd.RunCommand.acSaveRecord....
    In any event, I believe your line of code that blows up should be either:
    Code:
    Me.EmployeeID = .[EmployeeID]
    or explictly
    Code:
    Me.EmployeeID = myTable.[EmployeeID]
    Wendell

Posting Permissions

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