Using String Variables

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

Guest

I am transferring infomation from one form to another and need to get the
next available number from 1 of 5 tables. "HistoryTableValue" has the correct
table name in it but when I use it in a macro I get an action failed notice,
If I put in a table name it works.


Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)
 
Jim,

If I understand properly, [HistoryTableValue] is a field that contains the
name of the table you want to do the DMax on. If so, lose the quotes around
it like this:

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

HTH,
Josh
 
That is correct [HistoryTableValue] is a field that contains the name of the
table I want to run DMax on but it will not work with or without the quotes.

Joshua A. Booker said:
Jim,

If I understand properly, [HistoryTableValue] is a field that contains the
name of the table you want to do the DMax on. If so, lose the quotes around
it like this:

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

HTH,
Josh

Jim T. said:
I am transferring infomation from one form to another and need to get the
next available number from 1 of 5 tables. "HistoryTableValue" has the correct
table name in it but when I use it in a macro I get an action failed notice,
If I put in a table name it works.


Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)
 
Jim,

Perhaps the field name cannot be resolved in your context. I Just noticed
you are doing this in a macro. Do you have a form open that has a field
bound to the HistoryTableValue field? If so, try preceding it with the form
name that it's from.

Format(Now(),"yy") & "-" & (DMax("[number]",
Forms!FormName![HistoryTableValue])+1)

HTH,
Josh

Jim T. said:
That is correct [HistoryTableValue] is a field that contains the name of the
table I want to run DMax on but it will not work with or without the quotes.

Joshua A. Booker said:
Jim,

If I understand properly, [HistoryTableValue] is a field that contains the
name of the table you want to do the DMax on. If so, lose the quotes around
it like this:

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

HTH,
Josh

Jim T. said:
I am transferring infomation from one form to another and need to get the
next available number from 1 of 5 tables. "HistoryTableValue" has the correct
table name in it but when I use it in a macro I get an action failed notice,
If I put in a table name it works.


Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)
 
This Works:
Format(Now(),"yy") & "-" & (DMax("[number]","Birdsall_History_Table")+1)

These do not work:
Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard].[HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue].Value)+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard].[HistoryTableValue].Value)+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue].[Value])+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","[Forms]![Switchboard]![HistoryTableValue].[Value]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
“[Forms]![Switchboard]![HistoryTableValue]â€)+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
“[Forms]![Switchboard].[HistoryTableValue]â€)+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
“[Forms]![Switchboard]![HistoryTableValue].Valueâ€)+1)

Format(Now(),"yy") & "-" & (DMax("[number]","
![HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax([HistoryTableValuel]![number])+1)

Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]","[Tables]![HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",[Tables]![HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",â€[Tables].[HistoryTableValue]â€)+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","[Tables]![HistoryTableValue].[Value]")+1)




Joshua A. Booker said:
Jim,

Perhaps the field name cannot be resolved in your context. I Just noticed
you are doing this in a macro. Do you have a form open that has a field
bound to the HistoryTableValue field? If so, try preceding it with the form
name that it's from.

Format(Now(),"yy") & "-" & (DMax("[number]",
Forms!FormName![HistoryTableValue])+1)

HTH,
Josh

Jim T. said:
That is correct [HistoryTableValue] is a field that contains the name of the
table I want to run DMax on but it will not work with or without the quotes.

Joshua A. Booker said:
Jim,

If I understand properly, [HistoryTableValue] is a field that contains the
name of the table you want to do the DMax on. If so, lose the quotes around
it like this:

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

HTH,
Josh

I am transferring infomation from one form to another and need to get the
next available number from 1 of 5 tables. "HistoryTableValue" has the
correct
table name in it but when I use it in a macro I get an action failed
notice,
If I put in a table name it works.


Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)
 
None of the approaches that have quotes around the field name are going to
work.

Are you certain that the field contains the proper table name? Are you sure
that the table has data in it (so that DMax has something to return)?

I just did a quick test, and had no problem.



--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jim T. said:
This Works:
Format(Now(),"yy") & "-" & (DMax("[number]","Birdsall_History_Table")+1)

These do not work:
Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard].[HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue].Value)+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard].[HistoryTableValue].Value)+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue].[Value])+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","[Forms]![Switchboard]![HistoryTableValue].[Value]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
"[Forms]![Switchboard]![HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
"[Forms]![Switchboard].[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
"[Forms]![Switchboard]![HistoryTableValue].Value")+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","
![HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax([HistoryTableValuel]![number])+1)

Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","[Tables]![HistoryTableValue]")+1)

Format(Now(),"yy") & "-" &
(DMax("[number]",[Tables]![HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]","[Tables].[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","[Tables]![HistoryTableValue].[Value]")+1)




Joshua A. Booker said:
Jim,

Perhaps the field name cannot be resolved in your context. I Just
noticed
you are doing this in a macro. Do you have a form open that has a field
bound to the HistoryTableValue field? If so, try preceding it with the
form
name that it's from.

Format(Now(),"yy") & "-" & (DMax("[number]",
Forms!FormName![HistoryTableValue])+1)

HTH,
Josh

Jim T. said:
That is correct [HistoryTableValue] is a field that contains the name
of the
table I want to run DMax on but it will not work with or without the quotes.

:

Jim,

If I understand properly, [HistoryTableValue] is a field that
contains the
name of the table you want to do the DMax on. If so, lose the quotes around
it like this:

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

HTH,
Josh

I am transferring infomation from one form to another and need to
get the
next available number from 1 of 5 tables. "HistoryTableValue" has
the
correct
table name in it but when I use it in a macro I get an action
failed
notice,
If I put in a table name it works.


Format(Now(),"yy") & "-" &
(DMax("[number]","[HistoryTableValue]")+1)
 
Yes the field contains the proper name, I had it appear on the first form to
make sure. The original line worked when I only had one table but when I
added other sites it does not seem to recognize the varaible.

Douglas J. Steele said:
None of the approaches that have quotes around the field name are going to
work.

Are you certain that the field contains the proper table name? Are you sure
that the table has data in it (so that DMax has something to return)?

I just did a quick test, and had no problem.



--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jim T. said:
This Works:
Format(Now(),"yy") & "-" & (DMax("[number]","Birdsall_History_Table")+1)

These do not work:
Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard].[HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue].Value)+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard].[HistoryTableValue].Value)+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
[Forms]![Switchboard]![HistoryTableValue].[Value])+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","[Forms]![Switchboard]![HistoryTableValue].[Value]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
"[Forms]![Switchboard]![HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
"[Forms]![Switchboard].[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax("[number]",
"[Forms]![Switchboard]![HistoryTableValue].Value")+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","
![HistoryTableValue]")+1)

Format(Now(),"yy") & "-" & (DMax([HistoryTableValuel]![number])+1)

Format(Now(),"yy") & "-" & (DMax("[number]","[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","[Tables]![HistoryTableValue]")+1)

Format(Now(),"yy") & "-" &
(DMax("[number]",[Tables]![HistoryTableValue])+1)

Format(Now(),"yy") & "-" & (DMax("[number]","[Tables].[HistoryTableValue]")+1)

Format(Now(),"yy") & "-" &
(DMax("[number]","[Tables]![HistoryTableValue].[Value]")+1)




Joshua A. Booker said:
Jim,

Perhaps the field name cannot be resolved in your context. I Just
noticed
you are doing this in a macro. Do you have a form open that has a field
bound to the HistoryTableValue field? If so, try preceding it with the
form
name that it's from.

Format(Now(),"yy") & "-" & (DMax("[number]",
Forms!FormName![HistoryTableValue])+1)

HTH,
Josh

That is correct [HistoryTableValue] is a field that contains the name
of
the
table I want to run DMax on but it will not work with or without the
quotes.

:

Jim,

If I understand properly, [HistoryTableValue] is a field that
contains
the
name of the table you want to do the DMax on. If so, lose the quotes
around
it like this:

Format(Now(),"yy") & "-" & (DMax("[number]",[HistoryTableValue])+1)

HTH,
Josh

I am transferring infomation from one form to another and need to
get
the
next available number from 1 of 5 tables. "HistoryTableValue" has
the
correct
table name in it but when I use it in a macro I get an action
failed
notice,
If I put in a table name it works.


Format(Now(),"yy") & "-" &
(DMax("[number]","[HistoryTableValue]")+1)
 
Back
Top