Linking table to an unbound form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to have a form with two fields for start date and end date
populate one row in a table. After looking on this site, I have this in the
After Update property on the start date field:

DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] =" &
Forms!F_MainMenu.StartDate

But I keep getting 0 records updated. Any suggestions?
 
Are you certain you want to do this? Your code (if it worked) would update
every record in your table with the same StartDate, not just one record. Is
this what you want to do?

If so, try delimiting your date variable:
DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] = #" &
Forms!F_MainMenu.StartDate & "#"

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Well, here's what I want it to do: I want to take the start and end date
from the form and put them into the RunDate table. The table will only have
one row - I want it to be updated/overwritten whenever a new date is put into
the start or end date fields. Will your code work for that, or is it
different?

Roger Carlson said:
Are you certain you want to do this? Your code (if it worked) would update
every record in your table with the same StartDate, not just one record. Is
this what you want to do?

If so, try delimiting your date variable:
DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] = #" &
Forms!F_MainMenu.StartDate & "#"

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


argear said:
I'm trying to have a form with two fields for start date and end date
populate one row in a table. After looking on this site, I have this in the
After Update property on the start date field:

DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] =" &
Forms!F_MainMenu.StartDate

But I keep getting 0 records updated. Any suggestions?
 
Then yes, it ought to work for that.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


argear said:
Well, here's what I want it to do: I want to take the start and end date
from the form and put them into the RunDate table. The table will only have
one row - I want it to be updated/overwritten whenever a new date is put into
the start or end date fields. Will your code work for that, or is it
different?

Roger Carlson said:
Are you certain you want to do this? Your code (if it worked) would update
every record in your table with the same StartDate, not just one record. Is
this what you want to do?

If so, try delimiting your date variable:
DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] = #" &
Forms!F_MainMenu.StartDate & "#"

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


argear said:
I'm trying to have a form with two fields for start date and end date
populate one row in a table. After looking on this site, I have this
in
the
After Update property on the start date field:

DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] =" &
Forms!F_MainMenu.StartDate

But I keep getting 0 records updated. Any suggestions?
 
I tried and it's still updating 0 rows.

Roger Carlson said:
Then yes, it ought to work for that.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


argear said:
Well, here's what I want it to do: I want to take the start and end date
from the form and put them into the RunDate table. The table will only have
one row - I want it to be updated/overwritten whenever a new date is put into
the start or end date fields. Will your code work for that, or is it
different?

Roger Carlson said:
Are you certain you want to do this? Your code (if it worked) would update
every record in your table with the same StartDate, not just one record. Is
this what you want to do?

If so, try delimiting your date variable:
DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] = #" &
Forms!F_MainMenu.StartDate & "#"

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


I'm trying to have a form with two fields for start date and end date
populate one row in a table. After looking on this site, I have this in
the
After Update property on the start date field:

DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] =" &
Forms!F_MainMenu.StartDate

But I keep getting 0 records updated. Any suggestions?
 
OK, here's what you can do to debug this. Declare a string variable and set
your embedded SQL statement equal to it, then Debug.Print it. Like this:

Dim strSQL as String
strSQL = "UPDATE [RunDates] Set[InputDateStart] = #" &
Forms!F_MainMenu.StartDate & "#"
Debug.Print strSQL

Put this code just before your DoCmd line, then put a breakpoint on the
DoCmd.

Run the form and enter a value. The code will stop on your DoCmd line, but
your SQL String will appear in the Immediate Window below WITH the actual
values from the form. Cut and paste this SQL into a new query (in SQL View)
and execute the query. You'll should get some indication of what is going
on.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L



argear said:
I tried and it's still updating 0 rows.

Roger Carlson said:
Then yes, it ought to work for that.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


argear said:
Well, here's what I want it to do: I want to take the start and end date
from the form and put them into the RunDate table. The table will
only
have
one row - I want it to be updated/overwritten whenever a new date is
put
into
the start or end date fields. Will your code work for that, or is it
different?

:

Are you certain you want to do this? Your code (if it worked) would update
every record in your table with the same StartDate, not just one
record.
Is
this what you want to do?

If so, try delimiting your date variable:
DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] = #" &
Forms!F_MainMenu.StartDate & "#"

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L


I'm trying to have a form with two fields for start date and end date
populate one row in a table. After looking on this site, I have
this
in
the
After Update property on the start date field:

DoCmd.RunSQL "UPDATE [RunDates] Set[InputDateStart] =" &
Forms!F_MainMenu.StartDate

But I keep getting 0 records updated. Any suggestions?
 

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

Back
Top