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 Programming / June 2007

Tip: Looking for answers? Try searching our database.

Populating the Fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Please Help - 29 Jun 2007 16:44 GMT
Hi all,

I have a combo box, a text box (a date field) and a check box in the Record
Source of a form.  Both combo box and text box are on the form and the check
box field is not on the form.  

What I like to do is I like to write a code to automatically populate
today's date in the text box and check the box after a user has selected a
value from the combo box.  If, for some reason, the user removes the value
from the combox box, the text box will not be populated and the check box
will not be checked for that record.  

So I have tried the following code in the BeforeUpdate, and it's not working:

if Me.[combobox] <> null then
 me.[textbox].value = now()
 me.[checkbox] = "Yes"
end if

Please help.  Thanks.
SteveS - 29 Jun 2007 18:00 GMT
You cannot check for NULLs that way. In fact, if you try If NULL = NULL then,
the condition will *always* be False!!

Try this:

if Not IsNull(Me.[combobox])  then
 me.[textbox].value = now()
 me.[checkbox] = TRUE     ' not "Yes"
end if

HTH
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

> Hi all,
>
[quoted text clipped - 16 lines]
>
> Please help.  Thanks.
Please Help - 29 Jun 2007 18:30 GMT
Hi SteveS,

Thanks for your help.  It does not seem to be working.  

When I have my cursor in the combo box field (before even selecting a
value), today's date automatically populates in the text box and a check also
automatically populates in the check box.  If I select a value and then
remove it, both text and check box won't remove the date and check,
respectively.  

My combo box displays a name on the form but populates an ID (numeric data
type) of that name in the table.  

I inserted your code in the BeforeUpdate of the combo box.  Did I do
something wrong?

Thanks.

> You cannot check for NULLs that way. In fact, if you try If NULL = NULL then,
> the condition will *always* be False!!
[quoted text clipped - 28 lines]
> >
> > Please help.  Thanks.
SteveS - 29 Jun 2007 20:22 GMT
You don't have code to remove the values in the controls.

I would probably have the code in the combo box after update event.

Try this:

   If IsNull(Me.[combobox])  then
     Me.[textbox] = NULL
     Me.[checkbox] = FALSE
  Else
     Me.[textbox] = now()
     Me.[checkbox] = TRUE
   End If

HTH
Signature

Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

> Hi SteveS,
>
[quoted text clipped - 46 lines]
> > >
> > > Please help.  Thanks.
Please Help - 29 Jun 2007 21:06 GMT
Hi SteveS,

Thanks again for your helps.  For some reason, it only records the checkbox
in the table.  The combo box and the text field values are not recorded in
the table.  

Do you know why?

Thanks.

> You don't have code to remove the values in the controls.
>
[quoted text clipped - 62 lines]
> > > >
> > > > Please help.  Thanks.
Please Help - 29 Jun 2007 21:48 GMT
SteveS,

I want to thank you again for your helps.  Please ignore my previous
message.  I forgot that I had a query set up to erase both combo box and text
field in the table.  

You code works perfectly.  

Thanks again.  Have a nice weekend.

> You don't have code to remove the values in the controls.
>
[quoted text clipped - 62 lines]
> > > >
> > > > Please help.  Thanks.
 
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.