Thanks again Allen, That worked beautifully!!
One little issue, one line posted as
Do While IsNull(DLookup("EmpID","Emp", "EmpID = """ & strUser & """) And Not
Cancel
And I'm guessing that the """ got converted some where from single quotes to
double quotes.
When I first looked at it, I just figured he knows something, I don't (a lot)
maybe I didn't fully understand what I read, but it errored out and after I
changed it to
' " & strUser & " ' ")) without spaces, everything worked great.
Thanks again for all the help, this is so much better then what I would have
come up with..
I am still working on getting the empid from the emp form to the task form but I
will work on that for a few days before I post a new thread...
AGAIN, Thank you, and I hope you have a great weekend!!!
=================================================
"WANNABE" <SameAsB4> wrote in message
Sorry about any name confusion, not
working from the office today and I
forgot to change my screen name..
"Bob" <SameAsB4> wrote in message
bl...
Would not have taken it any other way,
clearly your perception of my intent
justifies deep concern and shivers up
your (and My) spine. (I understood)....
Thank you very much, I just opened this
and it looks like what I was looking
for. What I was working on was close,
not really
. This is much more, what
I had was the dlookup and a couple of if
statements. Now my test to myself is to
get it implemented and working, with no
more help. I will post my success or
failure. Thank you again...
========================================
=====
"Allen Browne"
message
bl...
So, you want to open another form where
the user can enter their details
before this one proceeds.
Private Sub Form_Open(Cancel As Integer)
Dim strUser as String
Dim iTryCount as Integer
strUser = Environ("username")
Do While IsNull(DLookup("EmpID",
"Emp", "EmpID = """ & strUser & """)
And Not Cancel
iTryCount = iTryCount + 1
If iTryCount > 3 Then
Cancel = True
MsgBox "Ask your supervisor
for help."
DoCmd.Quit
End If
DoCmd.OpenForm "frmEmp",
DataMode:=acFormAdd, _
WindowMode:=acDialog,
OpenArgs:=strUser
Loop
End Sub
The other form will need to be opened
modally and in data entry mode, and
you can then test whether it succeeded.
You can pass the new emp value in
OpenArgs, and then use the events of the
target form to put it into the new
record for you.
(BTW, what's horrifying is not you, but
the concept of automatically
creating a record every time a visits
the new record.)
--
Allen Browne - Microsoft MVP. Perth,
Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne
at mvps dot org.
"WANNABE" <breichenbach AT istate DOT
com> wrote in message
gbl...
anathema = Any person or thing that is intensely disliked.
OK. I have done a very poor job of
explaining this project, allow me to
try one last time
There are only 2 tables (EMP and
TASKS) EMP holds one record per user and
each user needs to have a record
before they can enter task information.
When they open the task form, a check
is done to match their login ID to a
field in the EMP table, if there is NO
match then the emp form needs to
open, allow them to create there
record, close and return the user to the
task form.
Here is the field structure for each table;
EMP
EmpID AutoNumber
FirstName Text
LastNAme Text
Phone Text
UserID Text
TASKS
TaskID AutoNumber
EmpID Text
TaskType Text
........
UserId auto fills from the default properties of the form
<<environ("username")>> and this is
what is tested when the task for
opens.
So, if that is any more clear, do you
have any suggestions as to how to
best code the test, and then if no
match open the emp form and return to
the task form only upon completing an emp record...
Thanks.
"Allen Browne"
..gbl...
BeforeUpdate event if there is no record
in
the main form, so the user enters the primary record first.
If you wrote the code (or have rights to it), you can post the code in a
new thread. Prefix the thread name with "INF:" or "Solution:" or
something that indicates your thread is not a request for help but a
solution or information offered.
"WANNABE" <breichenbach AT istate DOT com> wrote in message
bl...
Thanks Allen, This worked fine,
=DLookUp("EmpID","Emp","UserID='" & [UserID] & "'")
I've bookmarked your ELookup for later, not needed here but surely soon.
The Other part of my question now is.>
If when this form is opened, the value in Emp.EmpID is NULL, (that means
that no mother record exists, and one needs to be created before the
project form can be filled in. I'm thinking that it would be VBA code
On Open Procedure that tests the Emp.EmpID field and if NULL opens the
EmpEntry Form to create that record first. I appreciate any thoughts
and comments..
procedure that I would like to share,
wheresomething I thought of, but I'm sure I
had(IfNotInList) prompts if you would like
to