Access field doesn't allow data entry

  • I've got a subform with 2 fields: FIELD_1 is a list field with 3 values (1,0,-1, numeric type in the SQL table), FIELD_2 is a date type (date type in the SQL table). Both come from a table. When the user chooses one of the values in FIELD_1, using an event FIELD_2 captures and shows the current date. This works fine.

    The problem? I want the user to be able to edit that date and change it if necessary, but FIELD 2 doesn´t allow edition. This must be pretty basic but.... Where or how can you configure a given field to allow entry in a subform?

    I can't see the property (if it´s a property!) anywhere.

    Thanks all in advance, A.

  • Hello,

    You can use Microsoft Date and Time Picker Control. It has Value property.

  • View the properties for the field, on the data tab make sure Enabled = Yes and Locked = No. Also view the properties for the form and make sure that Allow Edits = Yes and Data Entry = No. (That last one is a little counter intuitive. If set to Yes you can only add new records.)

  • Thanks both, I'll check that. Could also be the source of the query the cause of not being able to edit the form??

    The source in this case is a SQL query (don't have access to it now), in this case is the form editable?

  • a_ud (12/23/2010)


    Thanks both, I'll check that. Could also be the source of the query the cause of not being able to edit the form??

    The source in this case is a SQL query (don't have access to it now), in this case is the form editable?

    You need to make the date object unbound and then you can play with it on the code. Then you can also use AfterUpdate event and run some code if user changes the date.

  • This may be a bit over simplified, but I usually do something like this:

    Set the form's Record Source:

    SELECT tblQuote.QuoteDate FROM tblQuote WHERE Quote = '2007-5434A';

    Then adjust the Record Source via the List's update event:

    Private Sub List_AfterUpdate()

    Dim strSQL As String

    Dim stWhere As String

    strSQL = "SELECT QuoteDate FROM tblQuote WHERE Quote = '"

    Select Case List4.Value

    Case 1

    stWhere = "2007-5434A" & "';"

    Case 0

    stWhere = "2007-5405A" & "';"

    Case -1

    stWhere = "2007-5403A" & "';"

    End Select

    strSQL = strSQL & stWhere

    Me.RecordSource = strSQL

    End Sub

    As long as the form and field properties are set as mentioned above I can edit the date.

    It is possible that your query doesn't return an editable record set in which case you may have to do it some other way. You may be able to check the query through the form's Record Source Property. If the record source is being set by code you can do a debug.print where it is being set, create a new query in access, select View > SQL View, then copy and paste the query string into the query design window. Run it and see if you can edit it.

  • Does your table reside in sql server? if so, there must exist a primary key in it

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply