Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error adding a New Record 1

Status
Not open for further replies.

Jonath

Technical User
Joined
Jul 13, 2007
Messages
27
Location
FR
Hi,

i have a form "recherche" where a user can enter a search criteria (in a field 'Name' for instance)

For this field, on Lostfocus event, I have:

----------
docmd.openform "enqueteur",,"byname"
'byname is a requery...the research works fine
if Forms![enqueteur].Newrecord then
answer=MsgBox("No result.Create New Record?",vbyesno)

if answer=vbno then
Me.name.setfocus
else
'Here I want to add a new record but had an error whatever I tried :-(

end if
end if
-----------

I tried: - forms![enqueteur].filteron=false
docmd.gotorecord,,acnewrec
'error: can't go to specified record

- declaring database and recordset, then
rs.addnew
'I have no error but no record is created?!?!

- I checked: edits are allowed

- I didn't find a solution to my problem in other posts



All ideas are welcome, thanks in advance !!!


Jonath@Paris
 
Code:
if Forms![enqueteur].Newrecord then
  [COLOR=red]'At this point you've already established you are in add mode, i.e. NewRecord=True[/color]
  answer=MsgBox("No result.Create New Record?",vbyesno)

  if answer=vbno then 
      Me.name.setfocus
  else
   'Here I want to add a new record but had an error whatever I tried 
   [COLOR=red]'You don't need to do anything, NewRecord = True, so all the user has to do is start filling in the fields and a new record will be created[/color]
  end if
end if


 
thanks a lot Joeatwork!! works fine now

here's a star for you :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top