help with coding - open a form in dialog window

G

Guest

Hi all,

I am trying to open a new form using a button on my form. Using Access 2003.
In the button click event i have asked to open a new instance of the form
"add projects"

Right now when i click the add button a new blank form for data entry is
available but i want it to pop out and the user types in the entry. I am
getting syntax errors like ProjectID control name not found in the requery
statement.


My table is very simple.

tblprojects
ProjectID - autonumber
Pno - Project number - primary key
Pname - Project name

what am i doing wrong. I was trying to use this as a macro the same error
popped up , so i converted it into vb code. Any help will be greatly
appreciated as i have to pop up many more forms for data entry.

Private Sub add_record_Click()
On Error GoTo add_record_Click_Err

DoCmd.OpenForm "Add Projects", acNormal, "", "", acAdd, acDialog
DoCmd.GoToRecord , , acNewRec
DoCmd.Requery , "ProjectID"
add_record_Click_Exit:
Exit Sub

add_record_Click_Err:
MsgBox Error$
Resume add_record_Click_Exit

End Sub



thanks in advance
 
G

Guest

Get rid of the Requery line.
Until you have added a record there is no ProjectID created...

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top