Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Jgk is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    46

    Where would I put code I tried in on load event each way. Run time error 2248, how do you bind in option 1
    thanks for your help,

  2. #17
    Jgk is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    46
    It opens to new record so shows me.contractor = null

  3. #18
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Binding a control is just setting the ControlSource property to a field of the RecordSource, just as you have done with other textboxes in the Detail section.

    The code will go in the Load event, same as you have for setting value of the other textboxes.

    Contractor field in ProjectHours table is number type. The value in txtContract is text. If you want to save the Contractor ID then need to pull that value over to the form.
    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.

  4. #19
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Use Design View ofyour form vs. using Layout View.

  5. #20
    Jgk is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    46
    I am getting closer, here is sql

    SELECT [Project Hours].*, [Project Hours].Contractor
    FROM [Project Hours]
    WHERE ((([me].[Contractor])=[Me].[txtContractor])); this is how I was trying to get contractor to go to Project Hours table, but did not work no error codes.

    in detail I have contractor =[txtContractor]

    Private Sub Form_Load()
    Dim iEdit As Integer

    'populate the text boxes
    Me.txtName = Environ("username")
    Me.txtDate = Date
    Me.txtContractor = DLookup("Contractor", "Contractors", "Login='" & Forms!FrmMenu!txtUser & "'")

    'set edit permissions
    iEdit = Forms!FrmMenu!txtLevel.Value
    Select Case iEdit
    Case Is < 2
    Me.AllowEdits = False
    Case Else
    Me.AllowEdits = True
    End Select
    End Sub

    This pulls info to form correctly. But the field in form header txtcontractor is still unbound, tried all combinations any thoughts thanks

  6. #21
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You haven't followed the instructions.

    Set the Contractor textbox ControlSource property in the Properties Sheet with field name from the RecordSource.

    You don't show the additional code in the procedure to populate Contractor textbox.

    However, there is a conflict of datatypes as noted in post 18.
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Saving field values to a table
    By SltPhx in forum Forms
    Replies: 3
    Last Post: 02-27-2014, 11:58 AM
  2. Replies: 1
    Last Post: 01-24-2014, 01:21 PM
  3. Saving A Calculated Field In A Table
    By HectorTheInspector in forum Forms
    Replies: 2
    Last Post: 10-06-2013, 07:15 AM
  4. Auto-fill field not saving to table
    By aaid in forum Forms
    Replies: 1
    Last Post: 12-18-2009, 05:34 PM
  5. Auto Populated Field not Saving to Table
    By EstesExpress in forum Forms
    Replies: 4
    Last Post: 10-09-2009, 03:33 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