Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
  1. #16
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Going back to post #8 -

    This line is incorrect: If IsNull(Me.ReceivedBy) Then Me.txtReceivedBy = [Forms]![LoginForm]![cboUser].[Column](1)



    "Column" cannot be in square brackets - it is a property, not a field or control name, and properties can't be in square brackets.

    It should be: If IsNull(Me.ReceivedBy) Then Me.txtReceivedBy = [Forms]![LoginForm]![cboUser].Column(1)



  2. #17
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by John_G View Post
    Going back to post #8 -

    This line is incorrect: If IsNull(Me.ReceivedBy) Then Me.txtReceivedBy = [Forms]![LoginForm]![cboUser].[Column](1)

    "Column" cannot be in square brackets - it is a property, not a field or control name, and properties can't be in square brackets.

    It should be: If IsNull(Me.ReceivedBy) Then Me.txtReceivedBy = [Forms]![LoginForm]![cboUser].Column(1)


    To easy John thanks for clearing that up and it has sorted it nicely so cheers... s

    o does the debug > Compile pick up on these things?

  3. #18
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,142
    Compiling will pick up on incorrect spellings and missing controls.

    Put an error in deliberately and see if it spots it?

    Always make sure you have Option Explicit at the top of EVERY code module.
    You can make it the default in the database vba editor tools¬options require variable declaration.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #19
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by Minty View Post
    Compiling will pick up on incorrect spellings and missing controls.

    Put an error in deliberately and see if it spots it?

    Always make sure you have Option Explicit at the top of EVERY code module.
    You can make it the default in the database vba editor tools¬options require variable declaration.
    no worries, thanks ill try it out and add the declaration if not already.. what does it do?

  5. #20
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,142
    It forces you to declare every variable you use e.g.

    Dim sSomeString as String
    Dim iSomeInteger as Integer

    This is important as it will a) force data types correctly for their use. b) means the compiler will spot typo's for you, which will mean your code will more likely work as you expect it to.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #21
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    yeah right... I have implemented it....


    Are you aware if you can insert data from one form, to 2 different tables,

    e.g. - jobdetails (parent) Joineryunit (subform) and orders (subform) another form OrderDetails, also NewOrders

    at the moment the data is filtered from jobdetails to joineryunit with jobnumber

    when I pressed on a joineryunit it shows all the current order numbers for that one record in the Order form.... then if you double click the order it brings up the details of that order in a separate form. which is great.

    Im trying to work out if I can press on the joineryunit to bring up a NewOrder for that unit which then updates the order subform and OrderDetails form

    does that make sense?

  7. #22
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,142
    That sounds possible. You would need to requery the sub forms once the new data was entered.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  8. #23
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by Minty View Post
    That sounds possible. You would need to requery the sub forms once the new data was entered.
    to be honest I got no idea where to start have most the forms inplace and hyperlinks ready to go... would you use dmax im trying to see if that will work.

    how would you requery once the data was entered?

  9. #24
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    no worries, thanks ill try it out and add the declaration if not already.. what does it do?
    Another thing variable declaration (required or not) does is to not allow Nulls to be assigned to variables decalared as anything other than Variants.

    For example:

    Dim strTest as string
    strTest = Null

    will give you a runtime error. This can be a pain or useful, depending on your point of view, but it does catch a lot of errors.

    Referring to earlier post #17, I tried out using .[Column](0), with the square brackets, and the compiler did not catch it.

  10. #25
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    ReceivedBy field must be a Long Integer number type.

    I said change the GoodsEntry form RecordSource to include tblEmployees:

    SELECT tblOrderDetails.*, tblEmployees.UserName FROM tblEmployees RIGHT JOIN tblOrderDetails ON tblEmployees.EmployeeID_PK = tblOrderDetails.ReceivedBy;

    Instead of referencing query object, this SQL statement can go directly in the RecordSource property.


    Actually, the brackets around Column are not an issue. Certainly not needed but still works. Also, if the reference is used in a textbox, Access will add the [] for you.

    If IsNull(Me!ReceivedBy) Then Me.txtReceivedBy = Form_LoginForm.cboUser.[Column](0)
    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.

  11. #26
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    June7:

    Actually, the brackets around Column are not an issue.
    I think they can be an issue, depending on context. In my database I changed this:

    DoCmd.FindRecord Me![country_name].Column(0), acEntire, , acSearchAll

    to this

    DoCmd.FindRecord Me![country_name].[Column](0), acEntire, , acSearchAll

    and it gave me a runtime error "Wrong number of arguments or invalid property assignment"

    But this one worked:
    DuplicateLabel.Caption = Select_File.[Column](1)

    until I changed it to to this:
    DuplicateLabel.Caption = Me!Select_File.[Column](1)

    it failed again with the same message. It looks like adding the form reference causes it.

    Best to leave the square brackets off, IMO.

  12. #27
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Whether I used Me! or Me., VBA removed the [] for me before I could even finish typing the line. Ah, I can go back and type them in and they stay! Get the error on Me! but not Me. Use Me. to get intellisense popup tips.

    However, agree best to leave [] out. Just be aware Access will add them when used in textbox ControlSource expression.

    Also, the Column(x) reference will not work in query object.
    Last edited by June7; 01-25-2018 at 01:46 PM.
    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.

  13. #28
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by June7 View Post
    Whether I used Me! or Me., VBA removed the [] for me before I could even finish typing the line. Ah, I can go back and type them in and they stay! Get the error on Me! but not Me. I always use Me. so I get intellisense popup tips.

    However, agree best to leave [] out. Just be aware Access will add them when used in textbox ControlSource expression.

    Also, the Column(x) reference will not work in query object.
    no worries June7 thanks for that.

    im slowly getting my head wrapped around it, im only writing little codes at the moment while learning off codes I find and rearrange to suit my purpose..


    so column(x) doesn't work in query object is it best to record straight back to tables or is that's depending on the situation and record?

  14. #29
    ShaunG is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jan 2018
    Posts
    237
    Quote Originally Posted by John_G View Post
    Another thing variable declaration (required or not) does is to not allow Nulls to be assigned to variables decalared as anything other than Variants.

    For example:

    Dim strTest as string
    strTest = Null

    will give you a runtime error. This can be a pain or useful, depending on your point of view, but it does catch a lot of errors.

    Referring to earlier post #17, I tried out using .[Column](0), with the square brackets, and the compiler did not catch it.
    yeah id rather know if there are errors in what ive created or used... yea right good to know there could still be errors if compile comes back ok.

    regarding post #26

    im slowly getting there with writing smaller codes and referencing controls and forms or tables.... baby steps lol

    John_G in my post #21 I refer to a question you were helping me out on in another thread. it was regarding an ordernumber filter, Ive nearly got my head wrapped around the Dmax code you gave me but because of the way ive change my database I need to refer to 2 controls which are on separate tables....

    ive changed the database around again this morning once again from post#21, so that all users can see all info at once. I have 3 subforms on my parent, joineryunit(subform), orders(subform) and orderDetails(subform) and jobdetails(parent)

    I have linked Orders to joineryunit and in the process of linking orderdetails to orders....

    im trying to work out what the best way to assign a new order to a joineryunit that is double clicked on by hyperlink, the new Order will contain the Order and Orderdetail information in one form, I was thinking the dmax you gave me would work but I need to lengthen it for the extra controls and tables.

    do you think this is the right way to go?

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

Similar Threads

  1. Replies: 4
    Last Post: 10-12-2015, 12:16 PM
  2. INSERT INTO code not working properly.
    By Alphix in forum Forms
    Replies: 8
    Last Post: 11-12-2014, 04:10 PM
  3. Login form not working properly
    By papa yaw in forum Forms
    Replies: 2
    Last Post: 12-22-2012, 09:46 AM
  4. Login form is not working properly
    By papa yaw in forum Forms
    Replies: 1
    Last Post: 12-19-2012, 05:25 PM
  5. Msgbox And Search Code Not Working Properly
    By vampyr07au in forum Forms
    Replies: 1
    Last Post: 05-02-2011, 05:16 PM

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