Add new record button faulty (1 Viewer)

rik59

New member
Local time
Today, 09:57
Joined
Jun 17, 2014
Messages
16
This is my problem: I have two forms (both of which open in Form View) one is a Welcome form with a single button that says 'Click here to enter the database'. When it is clicked it opens a second form - the Staff Record Entry form. On this form I have two buttons 'Add a new Record' and 'Search for a record'. When I go through the 'Welcome' form to enter the database and the Staff Record Entry form opens, if I click on the 'Add a New Record button' I get the error message 'You can't go to the specified record'. However, if I decide to ignore the 'Welcome' form route and open the Staff Record Entry form directly, the Add New Record button works fine.
This is really frustrating and I am at a loss with this one.Any help would be much appreciated and please bear in mind that my ability to add code to buttons is really low! but always willing to have a go!
 

KenHigg

Registered User
Local time
Today, 04:57
Joined
Jun 9, 2004
Messages
13,327
Is the second form getting focus when it opens - ? You may try throwing a requery or a do events just before the new record line.
 

rik59

New member
Local time
Today, 09:57
Joined
Jun 17, 2014
Messages
16
Hi Ken,
Thank you for your response. Please bear with me but how will I know if it is getting focus when it opens and I'm not sure what you mean by 'a requery or a do events just before the new record line'.
 

KenHigg

Registered User
Local time
Today, 04:57
Joined
Jun 9, 2004
Messages
13,327
I assume your button has code that fires the new record thing ? Put your code before that (those) lines. Use Access Help or google to learn more about those commands.
 

JHB

Have been here a while
Local time
Today, 10:57
Joined
Jun 17, 2012
Messages
7,732
How do you open the "Staff Record Entry" form from the "Welcome" form?
Show the code.
 

rik59

New member
Local time
Today, 09:57
Joined
Jun 17, 2014
Messages
16
The Welcome screen has a single button on it titled 'nter Database' which takes you through to the Staff Record Entry Form.
The code for this button from the Open Form Macro:

OpenForm
Form Name: Staff Record Entry Form
View: Form
Filter Name
Where Condition:
Data Mode: Read Only
Window Mode: Normal

Clicking on this buton works fine and takes you through to the Staff Record Entry Form. However, the The Add Record button on the Staf Record Entry form just throws up an error 'You Can't go to the Specified Record' every time it is clicked. The Search Record and Print Record buttons also on this page work fine.

Looking at the VBA for this button shows three windows:
1. Performance Management Report_Staff Record Report
Private Sub Command 62_Click()
End Sub

2. Performance Management [Form_Welcome (Code)]
Private Sub Form_Click()
End Sub

3. Performance Management [Form_Staff Record Entry form (Code)]
Private Sub Command76_Click()
End Sub
Private Sub Form_Click()
End Sub

I don't know if this helps.
 
Last edited:

GinaWhipp

AWF VIP
Local time
Today, 04:57
Joined
Jun 21, 2011
Messages
5,899
Hmm, that VBA does nothing and should be removed. And, I can't tell which is the Add New Record button by the name of your Command Buttons. Can you upload a sample file? Please remove all sensitive information first.
 

JHB

Have been here a while
Local time
Today, 10:57
Joined
Jun 17, 2012
Messages
7,732
..
OpenForm
Form Name: Staff Record Entry Form
View: Form
Filter Name
Where Condition:
Data Mode: Read Only
Window Mode: Normal
...
I think the problem here is that you set the form as "Read only"!
 

rik59

New member
Local time
Today, 09:57
Joined
Jun 17, 2014
Messages
16
Hi Gina,
Many thanks for your offer to have a look at the database.
Please see attached
 

Attachments

  • PM Database.accdb
    1.3 MB · Views: 58

GinaWhipp

AWF VIP
Local time
Today, 04:57
Joined
Jun 21, 2011
Messages
5,899
Hmm, I see there were a few issues...

1. As suggested by JHB, removed the *Data Mode: Read Only*
2. On the Staff Record Entry form changed *Data Entry* to *No* from *Yes*
3. Removed all useless lines behind Staff Record Entry form

Performance Management Report_Staff Record Report
Code:
Private Sub Command 62_Click()
End Sub

Performance Management [Form_Welcome
Code:
Private Sub Form_Click()
End Sub

Performance Management [Form_Staff Record Entry form
Code:
Private Sub Command76_Click()
End Sub
Private Sub Form_Click()
End Sub

4. NOT DONE - You need to change the name of the field *Date* in the table *Staff Record*. This IS going to cause you problems because it is a Reserved Word for Access, so change that to something like dteDate. For a complete list of Reserved Words...
http://allenbrowne.com/AppIssueBadWord.html

5. NOT DONE - you have a Reviewee table, a Reviewer table and a Staff table. This seems odd. Are the Reviewer's people from outside the School? Are the Staff the ones being reviewed? And the Staff Record table does not contain a Staff Record but more like the Review questions, is there's a table missing or it needs renamed. Based on the answers to these two questions and the Staff Record table observation your tables might need modifications.

I have reattached the database, see if your initial issue is resolved.
 

Attachments

  • PM Database.accdb
    1.2 MB · Views: 57

rik59

New member
Local time
Today, 09:57
Joined
Jun 17, 2014
Messages
16
Hi Gina and to all the rest that made suggestions to try and help out.
Huuuuuge thank you for sorting it out. You made it sound so obvious and easy but I have learned a lot just from this mistake.
Gina, I have taken on board your suggestion relating to the work not done, many thanks for that information also.
I can now progress this project further as a result.
 

GinaWhipp

AWF VIP
Local time
Today, 04:57
Joined
Jun 21, 2011
Messages
5,899
No problem, glad to help! And.... standing by if you need any additional help! :D
 

Users who are viewing this thread

Top Bottom