Display a specific record by clicking an open form button in MS Access 2007 doen't work
Assume I have 2 tables in MS Access:
Table about some people which work for some company:
And table about some projects which some company holds:
I also have two corresponding forms for tables (the question is typed on the big button):
I have searched in internet for a solution, I tried some, but 开发者_Go百科haven't achieved a desired goal, here are two of them:
DoCmd.OpenForm "Project_readonly", , , "People_readonly.[Project_ID] = " & Me![id]
DoCmd.OpenForm "Project_readonly", , , _
"People_readonly.[Project_ID] = '" & _
Project_readonly.id & "'"
Also while searching I found many other people having the same problem, they try some queries, but they don't work. Some also say that Wizard has some errors, so that it doen't produce working code. So I ask if is it possible that one filled the code for the attached BD file of mine and upload it here? Would be much thanks! Here is the file: http://www.sendspace.com/file/pf9tov . If you provide your solution, it would be also very good if you explain how it works!
Also please provide a good tutorial which exmplains Visual Basic clearly, whithout overbloat and specifically for MS Access usage, I have found some, but they are for windows forms.
I think the problem is here:
DoCmd.OpenForm "Project_readonly", , , "People_readonly.[Project_ID] = " & Me![id]
With the Record Source for your People_readonly form as the Project table, you want the WhereCondition parameter to select the Project row whose Id value matches the current form's Project_ID value.
If that sounds right, try it this way:
DoCmd.OpenForm "Project_readonly", , , "Id = " & Me!Project_ID
I just solved a similar problem which may help you. In a form linked to a table, I created a button that advances to the current day's form/record.
-Created button
-Used SearchForRecord action
-Object type: Table (because I was referencing information in a table)
-Object name: *the name of the table referencing
-Record: First (because you're finding the first record matching the value you're searching for in the table)
-Where Condition: [Date]= Date() (searching for when the field [DATE] matches the current date)
You can try changing the object type to Form and object name to your form name, then change the where condition to be [Project_ID]= 2 . Hope this helps.
精彩评论