2 problems: Date and Combo Box

S

sara

I have a table with lots of dates. Some default to today
when the record is created (=Date()) and some default to
today (=Date()) when the user does something, like changes
an item on the record.

My problem is that while all seem to be set up the same
(mm/dd/yyyy as format in the table, or ShortDate), onthe
ChangeDate, I keep getting the TIME added to the table.
This causes reports not to select the changed record,
since the user only enters date. I just want the date - I
have no use for the time. Is there a way to do that? I
don't know what code you'd need to see, so I didn't
attach any for that.

2. I have the user choose a Dept and DeptName from a drop-
down combobox on a form. When I carry over the info to
the "add" form, the deptnumber comes over correctly, but
the name does not. The first department nanme in the list
shows, even tho the prior form is correct. Do I have to
put it into a combo box on the second form? I have the
row selection doing the query - 5 fields, bound on field 4
(DeptNum). DeptName is in field 5. (The first 3 are
MerchantKey, FirstName, LastName).


Here is my code: (Please forgive some - I'm a newbie to
Access forms, etc. the only "programmer" in my company -
any help/improvements are appreciated)

Private Sub cmdAddNewPO_Click()

On Error GoTo Err_cmdAddNewPO_Click

Dim PONum As Long
Dim MerchantKey As Long
Dim MerchFirstName As String
Dim MerchLastName As String
Dim DeptNum As Long
Dim DeptName As String

Dim ctl As Control


'Code from Access Day
Dim frm As Form

DeptName = Me.DeptName

' Put in some code HERE TO MAKE SURE PONUM IS UNIQUE
' Get some help -post?-on figuring out how to do this


'Subtract one day from Current date as default

DoCmd.OpenForm "FrmAddPO", , , acFormAdd,
acWindowNormal

Set frm = Forms!FrmAddPO

Do While Not CurrentProject.AllForms(frm.Name).IsLoaded
DoEvents
Loop

'Defaults for Record to add - Merchant Name and PODate
With Me
frm.PONum = Me.lngPONumtoAdd
frm.MerchantKey = Me.MerchantKey
frm.MerchFirstName = Me.MerchFirstName
frm.MerchLastName = Me.MerchLastName
frm.DeptNum = Me.DeptNum
frm.DeptName = Me.DeptName

End With

Exit_cmdAddNewPO_Click:
Exit Sub

Err_cmdAddNewPO_Click:
MsgBox Err.Description

End Sub

Thank you very much -
Sara
 
A

Allen Browne

Hi Sara

The records that are showing the time as well as the date are being set by:
=Now()
Find where that is, and replace it with =Date(). In future they will be
assigned just the date.

To fix the existing records:
1. Create a query into this table.
2. Change it to an Update query (Update on Query menu).
3. In the Update row under this field (named MyDate in this example), enter:
DateValue([MyDate])
4. Run the query. The time component is removed.


For your 2nd issue, you have a combo. Its bound column is DeptNum, and you
have that set to zero-width so the combo displays the DeptName. When you
copy the value of the combo to your other form, it shows the DeptNum, and
you want to show the DeptName? If that's the idea, then yes, you could use
another combo on the other form.

Alternatively, you could use a DLookup() expression if particularly did not
want to use a combo.
 
S

sara

Allen -
I checked the table (which has format ShortDate and NO
default value) for the field ChangeDate, and the form
(which has format mm/dd/yyyy and Default Value =Date())
and I still got a record, changed today with Date and Time
on the database. What could I still be doing wrong?
There are NO =Now() in my entire database application. I
have POData.mdb with the data, and POApp.Mde for the
application. I link to some static data tables in
StaticData.mdb.

Thanks,
Sara
-----Original Message-----
Hi Sara

The records that are showing the time as well as the date are being set by:
=Now()
Find where that is, and replace it with =Date(). In future they will be
assigned just the date.

To fix the existing records:
1. Create a query into this table.
2. Change it to an Update query (Update on Query menu).
3. In the Update row under this field (named MyDate in this example), enter:
DateValue([MyDate])
4. Run the query. The time component is removed.


For your 2nd issue, you have a combo. Its bound column is DeptNum, and you
have that set to zero-width so the combo displays the DeptName. When you
copy the value of the combo to your other form, it shows the DeptNum, and
you want to show the DeptName? If that's the idea, then yes, you could use
another combo on the other form.

Alternatively, you could use a DLookup() expression if particularly did not
want to use a combo.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I have a table with lots of dates. Some default to today
when the record is created (=Date()) and some default to
today (=Date()) when the user does something, like changes
an item on the record.

My problem is that while all seem to be set up the same
(mm/dd/yyyy as format in the table, or ShortDate), onthe
ChangeDate, I keep getting the TIME added to the table.
This causes reports not to select the changed record,
since the user only enters date. I just want the date - I
have no use for the time. Is there a way to do that? I
don't know what code you'd need to see, so I didn't
attach any for that.

2. I have the user choose a Dept and DeptName from a drop-
down combobox on a form. When I carry over the info to
the "add" form, the deptnumber comes over correctly, but
the name does not. The first department nanme in the list
shows, even tho the prior form is correct. Do I have to
put it into a combo box on the second form? I have the
row selection doing the query - 5 fields, bound on field 4
(DeptNum). DeptName is in field 5. (The first 3 are
MerchantKey, FirstName, LastName).


Here is my code: (Please forgive some - I'm a newbie to
Access forms, etc. the only "programmer" in my company -
any help/improvements are appreciated)

Private Sub cmdAddNewPO_Click()

On Error GoTo Err_cmdAddNewPO_Click

Dim PONum As Long
Dim MerchantKey As Long
Dim MerchFirstName As String
Dim MerchLastName As String
Dim DeptNum As Long
Dim DeptName As String

Dim ctl As Control


'Code from Access Day
Dim frm As Form

DeptName = Me.DeptName

' Put in some code HERE TO MAKE SURE PONUM IS UNIQUE
' Get some help -post?-on figuring out how to do this


'Subtract one day from Current date as default

DoCmd.OpenForm "FrmAddPO", , , acFormAdd,
acWindowNormal

Set frm = Forms!FrmAddPO

Do While Not CurrentProject.AllForms (frm.Name).IsLoaded
DoEvents
Loop

'Defaults for Record to add - Merchant Name and PODate
With Me
frm.PONum = Me.lngPONumtoAdd
frm.MerchantKey = Me.MerchantKey
frm.MerchFirstName = Me.MerchFirstName
frm.MerchLastName = Me.MerchLastName
frm.DeptNum = Me.DeptNum
frm.DeptName = Me.DeptName

End With

Exit_cmdAddNewPO_Click:
Exit Sub

Err_cmdAddNewPO_Click:
MsgBox Err.Description

End Sub

Thank you very much -
Sara


.
 
A

Allen Browne

So the field in the table has no default value.

Is there a text box on your form for this field? Does the text box have a
Default Value set?

Are you able to know what is in the MDE?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

sara said:
Allen -
I checked the table (which has format ShortDate and NO
default value) for the field ChangeDate, and the form
(which has format mm/dd/yyyy and Default Value =Date())
and I still got a record, changed today with Date and Time
on the database. What could I still be doing wrong?
There are NO =Now() in my entire database application. I
have POData.mdb with the data, and POApp.Mde for the
application. I link to some static data tables in
StaticData.mdb.

Thanks,
Sara
-----Original Message-----
Hi Sara

The records that are showing the time as well as the date are being set by:
=Now()
Find where that is, and replace it with =Date(). In future they will be
assigned just the date.

To fix the existing records:
1. Create a query into this table.
2. Change it to an Update query (Update on Query menu).
3. In the Update row under this field (named MyDate in this example), enter:
DateValue([MyDate])
4. Run the query. The time component is removed.


For your 2nd issue, you have a combo. Its bound column is DeptNum, and you
have that set to zero-width so the combo displays the DeptName. When you
copy the value of the combo to your other form, it shows the DeptNum, and
you want to show the DeptName? If that's the idea, then yes, you could use
another combo on the other form.

Alternatively, you could use a DLookup() expression if particularly did not
want to use a combo.


I have a table with lots of dates. Some default to today
when the record is created (=Date()) and some default to
today (=Date()) when the user does something, like changes
an item on the record.

My problem is that while all seem to be set up the same
(mm/dd/yyyy as format in the table, or ShortDate), onthe
ChangeDate, I keep getting the TIME added to the table.
This causes reports not to select the changed record,
since the user only enters date. I just want the date - I
have no use for the time. Is there a way to do that? I
don't know what code you'd need to see, so I didn't
attach any for that.

2. I have the user choose a Dept and DeptName from a drop-
down combobox on a form. When I carry over the info to
the "add" form, the deptnumber comes over correctly, but
the name does not. The first department nanme in the list
shows, even tho the prior form is correct. Do I have to
put it into a combo box on the second form? I have the
row selection doing the query - 5 fields, bound on field 4
(DeptNum). DeptName is in field 5. (The first 3 are
MerchantKey, FirstName, LastName).


Here is my code: (Please forgive some - I'm a newbie to
Access forms, etc. the only "programmer" in my company -
any help/improvements are appreciated)

Private Sub cmdAddNewPO_Click()

On Error GoTo Err_cmdAddNewPO_Click

Dim PONum As Long
Dim MerchantKey As Long
Dim MerchFirstName As String
Dim MerchLastName As String
Dim DeptNum As Long
Dim DeptName As String

Dim ctl As Control


'Code from Access Day
Dim frm As Form

DeptName = Me.DeptName

' Put in some code HERE TO MAKE SURE PONUM IS UNIQUE
' Get some help -post?-on figuring out how to do this


'Subtract one day from Current date as default

DoCmd.OpenForm "FrmAddPO", , , acFormAdd,
acWindowNormal

Set frm = Forms!FrmAddPO

Do While Not CurrentProject.AllForms (frm.Name).IsLoaded
DoEvents
Loop

'Defaults for Record to add - Merchant Name and PODate
With Me
frm.PONum = Me.lngPONumtoAdd
frm.MerchantKey = Me.MerchantKey
frm.MerchFirstName = Me.MerchFirstName
frm.MerchLastName = Me.MerchLastName
frm.DeptNum = Me.DeptNum
frm.DeptName = Me.DeptName

End With

Exit_cmdAddNewPO_Click:
Exit Sub

Err_cmdAddNewPO_Click:
MsgBox Err.Description

End Sub

Thank you very much -
Sara
 
S

sara

There is a text box on the form and it has default Value
=Date(). It is a HIDDEN field - it's on the form (so I
know when in design that I'm adding it in this piece of
the application), but I wouldn't think that would matter.

Yes, I think I know what's in the MDE. I work on the app
in TEST. When changes are ready, I copy the MDB to a
folder on the production server called "MDB". I link the
tables to production tables, then create the MDE right
there. I cut the MDE from the MDB folder and paste it
into the POEntry folder the users access.

Is there any other way to look at the MDE to answer your
question?

I have other fields (DateEntered) that seem to work fine
(date only, no time) and look the same EXCEPT DateEntered
the default value =Date() is in the TABLE, as if a record
is added it MUST have the date added.

This is driving me crazy! (Of course, I haven't fixed the
dept number dept name issue yet, so that still has the
chance to drive me bonkers).

Thanks,
Sara
-----Original Message-----
So the field in the table has no default value.

Is there a text box on your form for this field? Does the text box have a
Default Value set?

Are you able to know what is in the MDE?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Allen -
I checked the table (which has format ShortDate and NO
default value) for the field ChangeDate, and the form
(which has format mm/dd/yyyy and Default Value =Date())
and I still got a record, changed today with Date and Time
on the database. What could I still be doing wrong?
There are NO =Now() in my entire database application. I
have POData.mdb with the data, and POApp.Mde for the
application. I link to some static data tables in
StaticData.mdb.

Thanks,
Sara
-----Original Message-----
Hi Sara

The records that are showing the time as well as the
date
are being set by:
=Now()
Find where that is, and replace it with =Date(). In future they will be
assigned just the date.

To fix the existing records:
1. Create a query into this table.
2. Change it to an Update query (Update on Query menu).
3. In the Update row under this field (named MyDate in this example), enter:
DateValue([MyDate])
4. Run the query. The time component is removed.


For your 2nd issue, you have a combo. Its bound column
is
DeptNum, and you
have that set to zero-width so the combo displays the DeptName. When you
copy the value of the combo to your other form, it shows the DeptNum, and
you want to show the DeptName? If that's the idea, then yes, you could use
another combo on the other form.

Alternatively, you could use a DLookup() expression if particularly did not
want to use a combo.


I have a table with lots of dates. Some default to today
when the record is created (=Date()) and some default to
today (=Date()) when the user does something, like changes
an item on the record.

My problem is that while all seem to be set up the same
(mm/dd/yyyy as format in the table, or ShortDate), onthe
ChangeDate, I keep getting the TIME added to the table.
This causes reports not to select the changed record,
since the user only enters date. I just want the
date -
I
have no use for the time. Is there a way to do that? I
don't know what code you'd need to see, so I didn't
attach any for that.

2. I have the user choose a Dept and DeptName from a drop-
down combobox on a form. When I carry over the info to
the "add" form, the deptnumber comes over correctly, but
the name does not. The first department nanme in the list
shows, even tho the prior form is correct. Do I have to
put it into a combo box on the second form? I have the
row selection doing the query - 5 fields, bound on field 4
(DeptNum). DeptName is in field 5. (The first 3 are
MerchantKey, FirstName, LastName).


Here is my code: (Please forgive some - I'm a newbie to
Access forms, etc. the only "programmer" in my company -
any help/improvements are appreciated)

Private Sub cmdAddNewPO_Click()

On Error GoTo Err_cmdAddNewPO_Click

Dim PONum As Long
Dim MerchantKey As Long
Dim MerchFirstName As String
Dim MerchLastName As String
Dim DeptNum As Long
Dim DeptName As String

Dim ctl As Control


'Code from Access Day
Dim frm As Form

DeptName = Me.DeptName

' Put in some code HERE TO MAKE SURE PONUM IS UNIQUE
' Get some help -post?-on figuring out how to do this


'Subtract one day from Current date as default

DoCmd.OpenForm "FrmAddPO", , , acFormAdd,
acWindowNormal

Set frm = Forms!FrmAddPO

Do While Not CurrentProject.AllForms (frm.Name).IsLoaded
DoEvents
Loop

'Defaults for Record to add - Merchant Name and PODate
With Me
frm.PONum = Me.lngPONumtoAdd
frm.MerchantKey = Me.MerchantKey
frm.MerchFirstName = Me.MerchFirstName
frm.MerchLastName = Me.MerchLastName
frm.DeptNum = Me.DeptNum
frm.DeptName = Me.DeptName

End With

Exit_cmdAddNewPO_Click:
Exit Sub

Err_cmdAddNewPO_Click:
MsgBox Err.Description

End Sub

Thank you very much -
Sara


.
 
A

Allen Browne

Hi Sara

If you created the MDE, we don't need to worry about that aspect.

To debug this, you may want to start working backwards. Remove the default
value from the hidden text box, and enter something in the form. Does the
date/time still show up? Yes: where's it coming from? No: why is Access
interpreting this value like that?

Make sure you can see the century so you can pick up really weird dates such
around 1899. Maybe it is not understanding the data type somewhere, so
1/10/04 is being interpreted as 1 divided by 10 divided by 4.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

sara said:
There is a text box on the form and it has default Value
=Date(). It is a HIDDEN field - it's on the form (so I
know when in design that I'm adding it in this piece of
the application), but I wouldn't think that would matter.

Yes, I think I know what's in the MDE. I work on the app
in TEST. When changes are ready, I copy the MDB to a
folder on the production server called "MDB". I link the
tables to production tables, then create the MDE right
there. I cut the MDE from the MDB folder and paste it
into the POEntry folder the users access.

Is there any other way to look at the MDE to answer your
question?

I have other fields (DateEntered) that seem to work fine
(date only, no time) and look the same EXCEPT DateEntered
the default value =Date() is in the TABLE, as if a record
is added it MUST have the date added.

This is driving me crazy! (Of course, I haven't fixed the
dept number dept name issue yet, so that still has the
chance to drive me bonkers).

Thanks,
Sara
-----Original Message-----
So the field in the table has no default value.

Is there a text box on your form for this field? Does the text box have a
Default Value set?

Are you able to know what is in the MDE?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Allen -
I checked the table (which has format ShortDate and NO
default value) for the field ChangeDate, and the form
(which has format mm/dd/yyyy and Default Value =Date())
and I still got a record, changed today with Date and Time
on the database. What could I still be doing wrong?
There are NO =Now() in my entire database application. I
have POData.mdb with the data, and POApp.Mde for the
application. I link to some static data tables in
StaticData.mdb.

Thanks,
Sara
-----Original Message-----
Hi Sara

The records that are showing the time as well as the date
are being set by:
=Now()
Find where that is, and replace it with =Date(). In
future they will be
assigned just the date.

To fix the existing records:
1. Create a query into this table.
2. Change it to an Update query (Update on Query menu).
3. In the Update row under this field (named MyDate in
this example), enter:
DateValue([MyDate])
4. Run the query. The time component is removed.


For your 2nd issue, you have a combo. Its bound column is
DeptNum, and you
have that set to zero-width so the combo displays the
DeptName. When you
copy the value of the combo to your other form, it shows
the DeptNum, and
you want to show the DeptName? If that's the idea, then
yes, you could use
another combo on the other form.

Alternatively, you could use a DLookup() expression if
particularly did not
want to use a combo.


message
I have a table with lots of dates. Some default to today
when the record is created (=Date()) and some default to
today (=Date()) when the user does something, like
changes
an item on the record.

My problem is that while all seem to be set up the same
(mm/dd/yyyy as format in the table, or ShortDate), onthe
ChangeDate, I keep getting the TIME added to the table.
This causes reports not to select the changed record,
since the user only enters date. I just want the date -
I
have no use for the time. Is there a way to do that? I
don't know what code you'd need to see, so I didn't
attach any for that.

2. I have the user choose a Dept and DeptName from a
drop-
down combobox on a form. When I carry over the info to
the "add" form, the deptnumber comes over correctly, but
the name does not. The first department nanme in the
list
shows, even tho the prior form is correct. Do I have to
put it into a combo box on the second form? I have the
row selection doing the query - 5 fields, bound on
field 4
(DeptNum). DeptName is in field 5. (The first 3 are
MerchantKey, FirstName, LastName).


Here is my code: (Please forgive some - I'm a newbie to
Access forms, etc. the only "programmer" in my company -
any help/improvements are appreciated)

Private Sub cmdAddNewPO_Click()

On Error GoTo Err_cmdAddNewPO_Click

Dim PONum As Long
Dim MerchantKey As Long
Dim MerchFirstName As String
Dim MerchLastName As String
Dim DeptNum As Long
Dim DeptName As String

Dim ctl As Control


'Code from Access Day
Dim frm As Form

DeptName = Me.DeptName

' Put in some code HERE TO MAKE SURE PONUM IS UNIQUE
' Get some help -post?-on figuring out how to do this


'Subtract one day from Current date as default

DoCmd.OpenForm "FrmAddPO", , , acFormAdd,
acWindowNormal

Set frm = Forms!FrmAddPO

Do While Not CurrentProject.AllForms
(frm.Name).IsLoaded
DoEvents
Loop

'Defaults for Record to add - Merchant Name and PODate
With Me
frm.PONum = Me.lngPONumtoAdd
frm.MerchantKey = Me.MerchantKey
frm.MerchFirstName = Me.MerchFirstName
frm.MerchLastName = Me.MerchLastName
frm.DeptNum = Me.DeptNum
frm.DeptName = Me.DeptName

End With

Exit_cmdAddNewPO_Click:
Exit Sub

Err_cmdAddNewPO_Click:
MsgBox Err.Description

End Sub

Thank you very much -
Sara
 
G

Guest

ALlen -
I am so indebted to you!!! I followed your debug advice
and I found my problem. I have the box on the form set to
Date() AND I do any update query that was setting the
change date to NOW(). I am a pretty good problem-solver,
but as all this is new to me, I just didn't know where to
look. Removing the default from the form worked.

Before I go to solve the dept number/name problem, a
questions:
Should I have the udpate query do the date setting or the
form? (Obviously not both!) It is possible, even likely
that a user will change a changed record and I want to
keep the LATEST change date.

Also, any advice on "tracking" the changes? Would I save
the entire record and then somehow put the not equal
fields on a form/report? I guess the best form would be a
datasheet form if that's the route to go. I'm thinking
that if I ask for DESIGN help, maybe I won't have so much
trouble in the development!

Again, thanks a million. We have never had any systems to
help our company keep track of anything (I brought in PCs
2 years ago- took them off paper and pencil!), so this is
really exciting for us.
Sara
-----Original Message-----
Hi Sara

If you created the MDE, we don't need to worry about that aspect.

To debug this, you may want to start working backwards. Remove the default
value from the hidden text box, and enter something in the form. Does the
date/time still show up? Yes: where's it coming from? No: why is Access
interpreting this value like that?

Make sure you can see the century so you can pick up really weird dates such
around 1899. Maybe it is not understanding the data type somewhere, so
1/10/04 is being interpreted as 1 divided by 10 divided by 4.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

There is a text box on the form and it has default Value
=Date(). It is a HIDDEN field - it's on the form (so I
know when in design that I'm adding it in this piece of
the application), but I wouldn't think that would matter.

Yes, I think I know what's in the MDE. I work on the app
in TEST. When changes are ready, I copy the MDB to a
folder on the production server called "MDB". I link the
tables to production tables, then create the MDE right
there. I cut the MDE from the MDB folder and paste it
into the POEntry folder the users access.

Is there any other way to look at the MDE to answer your
question?

I have other fields (DateEntered) that seem to work fine
(date only, no time) and look the same EXCEPT DateEntered
the default value =Date() is in the TABLE, as if a record
is added it MUST have the date added.

This is driving me crazy! (Of course, I haven't fixed the
dept number dept name issue yet, so that still has the
chance to drive me bonkers).

Thanks,
Sara
-----Original Message-----
So the field in the table has no default value.

Is there a text box on your form for this field? Does
the
text box have a
Default Value set?

Are you able to know what is in the MDE?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Allen -
I checked the table (which has format ShortDate and NO
default value) for the field ChangeDate, and the form
(which has format mm/dd/yyyy and Default Value =Date ())
and I still got a record, changed today with Date and Time
on the database. What could I still be doing wrong?
There are NO =Now() in my entire database application. I
have POData.mdb with the data, and POApp.Mde for the
application. I link to some static data tables in
StaticData.mdb.

Thanks,
Sara
-----Original Message-----
Hi Sara

The records that are showing the time as well as the date
are being set by:
=Now()
Find where that is, and replace it with =Date(). In
future they will be
assigned just the date.

To fix the existing records:
1. Create a query into this table.
2. Change it to an Update query (Update on Query menu).
3. In the Update row under this field (named MyDate in
this example), enter:
DateValue([MyDate])
4. Run the query. The time component is removed.


For your 2nd issue, you have a combo. Its bound column is
DeptNum, and you
have that set to zero-width so the combo displays the
DeptName. When you
copy the value of the combo to your other form, it shows
the DeptNum, and
you want to show the DeptName? If that's the idea, then
yes, you could use
another combo on the other form.

Alternatively, you could use a DLookup() expression if
particularly did not
want to use a combo.


message
I have a table with lots of dates. Some default to today
when the record is created (=Date()) and some
default
to
today (=Date()) when the user does something, like
changes
an item on the record.

My problem is that while all seem to be set up the same
(mm/dd/yyyy as format in the table, or ShortDate), onthe
ChangeDate, I keep getting the TIME added to the table.
This causes reports not to select the changed record,
since the user only enters date. I just want the date -
I
have no use for the time. Is there a way to do that? I
don't know what code you'd need to see, so I didn't
attach any for that.

2. I have the user choose a Dept and DeptName from a
drop-
down combobox on a form. When I carry over the info to
the "add" form, the deptnumber comes over correctly, but
the name does not. The first department nanme in the
list
shows, even tho the prior form is correct. Do I
have
to
put it into a combo box on the second form? I have the
row selection doing the query - 5 fields, bound on
field 4
(DeptNum). DeptName is in field 5. (The first 3 are
MerchantKey, FirstName, LastName).


Here is my code: (Please forgive some - I'm a newbie to
Access forms, etc. the only "programmer" in my company -
any help/improvements are appreciated)

Private Sub cmdAddNewPO_Click()

On Error GoTo Err_cmdAddNewPO_Click

Dim PONum As Long
Dim MerchantKey As Long
Dim MerchFirstName As String
Dim MerchLastName As String
Dim DeptNum As Long
Dim DeptName As String

Dim ctl As Control


'Code from Access Day
Dim frm As Form

DeptName = Me.DeptName

' Put in some code HERE TO MAKE SURE PONUM IS UNIQUE
' Get some help -post?-on figuring out how to do this


'Subtract one day from Current date as default

DoCmd.OpenForm "FrmAddPO", , , acFormAdd,
acWindowNormal

Set frm = Forms!FrmAddPO

Do While Not CurrentProject.AllForms
(frm.Name).IsLoaded
DoEvents
Loop

'Defaults for Record to add - Merchant Name and PODate
With Me
frm.PONum = Me.lngPONumtoAdd
frm.MerchantKey = Me.MerchantKey
frm.MerchFirstName = Me.MerchFirstName
frm.MerchLastName = Me.MerchLastName
frm.DeptNum = Me.DeptNum
frm.DeptName = Me.DeptName

End With

Exit_cmdAddNewPO_Click:
Exit Sub

Err_cmdAddNewPO_Click:
MsgBox Err.Description

End Sub

Thank you very much -
Sara


.
 
A

Allen Browne

Hi Sara. Great: well done.

In general, it is better to make the change through the form, so as to avoid
the chance of a concurrency error, "Another user has changed..."

If you want to record details of all changes - edits, inserts, and
deletions - see:
Audit Trail - Log changes at the record level
at:
http://members.iinet.net.au/~allenbrowne/AppAudit.html
 
S

sara

Thanks, Allen. Couldn't have done it without you. And I
learned about Dlookup and am using that. All is well.

I'll look at your site for the next steps in my process;
if I get stuck, I'll post again - I guess I should start a
new thread in that case as it will be an entirely new
topic, right?

Again, thanks.
Sara
 

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