Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2007

Tip: Looking for answers? Try searching our database.

Adding a record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Amour - 22 Mar 2007 17:42 GMT
Hi,
  I am trying to add/update a table (tblTravel) I have a form (frmTravel)
previous to this form there is another form(frmMeeting) were the user clicks
on a button.  What I want that button to do is check if record exist.  There
is frmMeeting.field1 and frmMeeting.field2.  If field1 = tblTravel.field1 and
field2 = tblTravel.field2 then I want to update and bring up frmTravel with
all the fields in that record.  Else I want frmTravel to add a new record.
Pease Help and Thank you.
kingston - 22 Mar 2007 18:59 GMT
Try something like the following from the button on frmMeeting:

DoCmd.OpenForm "frmTravel",,,"[Field1]='" & Me.[Field1]  & "' AND [Field2]='"
& Me.[Field2] & "'"

Beware of unintended line breaks - the command should all be one line.

>Hi,
>   I am trying to add/update a table (tblTravel) I have a form (frmTravel)
[quoted text clipped - 4 lines]
>all the fields in that record.  Else I want frmTravel to add a new record.
>Pease Help and Thank you.
Amour - 22 Mar 2007 19:20 GMT
That is simular to what I am currently doing, but that only puts the
frmMeeting.field1 and frmMeeting.field2 up on the form (frmTravel).  It does
not check to see if it is already within the table (tblTravel).  If they
match then update otherwise (else) add new record.
Unless I am missing something.

> Try something like the following from the button on frmMeeting:
>
[quoted text clipped - 11 lines]
> >all the fields in that record.  Else I want frmTravel to add a new record.
> >Pease Help and Thank you.
kingston - 22 Mar 2007 19:40 GMT
Is frmTravel not directly bound to tblTravel?  If it is, the OpenForm command
will open the form and find record(s) that match the criteria (it doesn't put
the field values into frmTravel).  If there is no match, it will open to a
new record.  If you need to check for the existence of a record in tblTravel,
one way to do it is to use the DCount() function:

If DCount("*","tblTravel","Field1='"& Value1 & "' AND Field2='" & Value2 &
"'")= 0 Then...

>That is simular to what I am currently doing, but that only puts the
>frmMeeting.field1 and frmMeeting.field2 up on the form (frmTravel).  It does
[quoted text clipped - 7 lines]
>> >all the fields in that record.  Else I want frmTravel to add a new record.
>> >Pease Help and Thank you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.