|
|
I've given up. My condition for the macro is below but when I run the macro there is no message displayed and the balance of the macro does not run. What I need is that if the OffLedgerDate entered on the form (in text format yyyymmdd) is found in the DistDate field on the dbo_uTempLabor_All table AND if DayDots is found in the Corp field on the dbo_uTempLabor_all table, a message is to be displayed indicating that the data is already entered.
This is the condition and the action is a MsgBox. [Forms]![frmMain]![OffLedgerDate]=DLookUp("[DistDate]","dbo_uTempLabor_All") And "DayDots"=DLookUp("[Corp]","dbo_uTempLaborAll")
2nd line of macro has an Action of Stop Macro.
Any help would be very much appreciated. Thank you!
|
|
Jani,
DLookup("[DistDate]","dbo_uTempLabor_All") will return the value of the DistDate field in the first record of the table. If you want to know if it is in *any* record in the table, then DLookup is probably the wrong function. If I undertstand you correctly, I think this should work: DCount("*","dbo_uTempLabor_All","[DistDate]='" & [OffLedgerDate] & "'")
As for the other bit, I'm not sure I understand. You mean the literal text "DayDots"? And you want to test whether this appears in the Corp field in *any* record in the table?
-- Steve Schapel, Microsoft Access MVP
"Jani" <Jani[ at ]discussions.microsoft.com> wrote in message news:3E5DAAF0-2F4C-4237-A78A-D2CFAB614856[ at ]microsoft.com...
[Quoted Text] > I've given up. My condition for the macro is below but when I run the > macro > there is no message displayed and the balance of the macro does not run. > What > I need is that if the OffLedgerDate entered on the form (in text format > yyyymmdd) is found in the DistDate field on the dbo_uTempLabor_All table > AND > if DayDots is found in the Corp field on the dbo_uTempLabor_all table, a > message is to be displayed indicating that the data is already entered. > > This is the condition and the action is a MsgBox. > [Forms]![frmMain]![OffLedgerDate]=DLookUp("[DistDate]","dbo_uTempLabor_All") > And "DayDots"=DLookUp("[Corp]","dbo_uTempLaborAll") > > 2nd line of macro has an Action of Stop Macro. > > Any help would be very much appreciated. Thank you!
|
|
Thanks for the super quick response. I need to know if any record in the dbo_uTempLabor_All table has the in the DistDate field the same date as in the OffLedgerDate field on the form and also has "DayDots" in the same record in the Corp field. Am I making myself clear???
"Steve Schapel" wrote:
[Quoted Text] > Jani, > > DLookup("[DistDate]","dbo_uTempLabor_All") will return the value of the > DistDate field in the first record of the table. If you want to know if it > is in *any* record in the table, then DLookup is probably the wrong > function. If I undertstand you correctly, I think this should work: > DCount("*","dbo_uTempLabor_All","[DistDate]='" & [OffLedgerDate] & "'") > > As for the other bit, I'm not sure I understand. You mean the literal text > "DayDots"? And you want to test whether this appears in the Corp field in > *any* record in the table? > > -- > Steve Schapel, Microsoft Access MVP > > "Jani" <Jani[ at ]discussions.microsoft.com> wrote in message > news:3E5DAAF0-2F4C-4237-A78A-D2CFAB614856[ at ]microsoft.com... > > I've given up. My condition for the macro is below but when I run the > > macro > > there is no message displayed and the balance of the macro does not run. > > What > > I need is that if the OffLedgerDate entered on the form (in text format > > yyyymmdd) is found in the DistDate field on the dbo_uTempLabor_All table > > AND > > if DayDots is found in the Corp field on the dbo_uTempLabor_all table, a > > message is to be displayed indicating that the data is already entered. > > > > This is the condition and the action is a MsgBox. > > [Forms]![frmMain]![OffLedgerDate]=DLookUp("[DistDate]","dbo_uTempLabor_All") > > And "DayDots"=DLookUp("[Corp]","dbo_uTempLaborAll") > > > > 2nd line of macro has an Action of Stop Macro. > > > > Any help would be very much appreciated. Thank you! >
|
|
Jani,
Ok, try it like this: DCount("*","dbo_uTempLabor_All","[DistDate]='" & [OffLedgerDate] & "' And [Corp]='DayDots'")>0
Regards Steve
-- Steve Schapel, Microsoft Access MVP
"Jani" <Jani[ at ]discussions.microsoft.com> wrote in message news:24504D71-F85B-4D1D-AEDC-5CE19758F126[ at ]microsoft.com...
[Quoted Text] > Thanks for the super quick response. I need to know if any record in the > dbo_uTempLabor_All table has the in the DistDate field the same date as in > the OffLedgerDate field on the form and also has "DayDots" in the same > record > in the Corp field. Am I making myself clear???
|
|
This worked great! I just needed to add [Forms]![frmMain]! to OffLedgerDate. Thank you so much. Jani
"Steve Schapel" wrote:
[Quoted Text] > Jani, > > Ok, try it like this: > DCount("*","dbo_uTempLabor_All","[DistDate]='" & [OffLedgerDate] & "' And > [Corp]='DayDots'")>0 > > Regards > Steve > > -- > Steve Schapel, Microsoft Access MVP > > "Jani" <Jani[ at ]discussions.microsoft.com> wrote in message > news:24504D71-F85B-4D1D-AEDC-5CE19758F126[ at ]microsoft.com... > > Thanks for the super quick response. I need to know if any record in the > > dbo_uTempLabor_All table has the in the DistDate field the same date as in > > the OffLedgerDate field on the form and also has "DayDots" in the same > > record > > in the Corp field. Am I making myself clear??? > >
|
|
Jani,
Ah, ok. I assumed you were running the macro via an event on the frmMain form, in which case that would not be required, so I guess the macro is running from another form.
-- Steve Schapel, Microsoft Access MVP
"Jani" <Jani[ at ]discussions.microsoft.com> wrote in message news:25BC9EB1-2B9B-45CB-9FAC-523397B6A05A[ at ]microsoft.com...
[Quoted Text] > This worked great! I just needed to add [Forms]![frmMain]! to > OffLedgerDate. > Thank you so much. Jani >
|
|
|