Results 1 to 6 of 6
  1. #1
    spleewars is offline Novice
    Windows XP Access 2002
    Join Date
    Feb 2012
    Posts
    26

    Very strange issue: form opens blank

    Ok, my question seem rather to be either unresolvable. I have posted the following post on other forums to be honest but none replied or came with a decent idea:



    I've been struggling several time with this problem and apparently its driving me a little crazy: i have this code

    Code:
    Private Sub CodeNumber_DblClick(Cancel As Integer)
      DoCmd.OpenForm "Products", , , _
            "[products.codenumber]=" & "'" & Me.CodeNumber & "'"
           
       End Sub
    I cannot understand why on other forms this code works flawlessly and sometimes on others no. I have used this sort of code many other times on lots of other forms and worked properly but in this one, nope! The form automatically open on double click and where it is suppose to load the record, the form 'products' open itself with no loaded record.

    Further testing made: removed all code and enabled and unlocked some disabled fields from form Products, changed "'" with "", "#" and tried this code as well:

    Code:
    "[products.codenumber]=" & "'" & Forms![search_advancedstock]![search-advancedstock-datasheet].CodeNumber] & "'"
    again, Products form open but no record information is loaded...

    What is wrong?

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    What is the name of the control on the Products form that holds the code number? What is the name of the field in the record source that holds the code number? What is the datatype of that field?

  3. #3
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Regarding [products.codenumber], if the table name is products and the field name is codenumber, the correct syntax is [products].[codenumber] or just leave off the square brackes altogether since you do not have spaces in the names.

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    If you are seeing a completely blank form, without even blank fields showing, it means that no records matched the criteris you specified, i.e. "[products.codenumber]=" & "'" & Me.CodeNumber & "'" - there were no products with that code number.

    How you get around it depends on what you want to do; if all you want to do is look at the product list, then do a dcount to find out if there are any records; if there are none, display a message and do not open the form.

    If you want to add records and there are no existing ones, switch the form to data entry mode just after opening it, with DataEntry = True.

    If you are seeing the form with blank fields, and you know there is data that should be shown, the form may already be set to Data Entry = True (Yes), in which case it will never show existing data.

    HTH

    John
    Last edited by John_G; 06-01-2012 at 08:22 AM. Reason: correct for finger trouble!

  5. #5
    spleewars is offline Novice
    Windows XP Access 2002
    Join Date
    Feb 2012
    Posts
    26
    Thanks guys of your input. Actually thanks to jzwp11 i became conscious that everything was passing through a very complex query and its statement was not reversible to make things work as i meant to. I solved the problem by creating a new query and setting new statements where required.

    Again guys, thanks and have a great weekend

  6. #6
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-11-2012, 11:52 AM
  2. Replies: 1
    Last Post: 05-03-2012, 02:25 PM
  3. Replies: 11
    Last Post: 01-26-2012, 01:22 PM
  4. Replies: 1
    Last Post: 12-04-2011, 09:11 PM
  5. Replies: 2
    Last Post: 02-26-2010, 08:14 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