inputing data with form (1 Viewer)

R

rintaro

Guest
i'm pretty much a rookie at access, so this may be a stupid question. i have a db with productivity info and another with employee info. i want to create a form where a clerk can input an employee number, have the name pop up, and then input the data for the day. the problem is i have no idea how to do this. i've tried tying the form to the productivity table and the employee table with no luck, all i get is a form that looks up records for that employee. the best i've been able to do is to be able to bring up the name from the employee number (don't ask how, i think it was a fluke!). is ther anything special i need to do to designate the form as an input form or something?
 

KDg

Registered User.
Local time
Today, 14:41
Joined
Oct 28, 1999
Messages
181
If you're happy with the data being input by your clerk ( no nulls, garbage etc).

I'd create an Unbound text box on the form ( just drop one on and it will be as the default) and do some code in the background.
This is probably a bit beyond total newbie but if you need more just post back here.
Go into the On_Exit event of the box that Employee ID is being entered into and use code similar to this ( you'll need to change it to fit your table and field names ) -

sub My_box_On_Exit
dim strSQL as string
dim rst as recordset
dim dbs as database

set dbs = currentdb ' could be another if you want

let strSQL= "SELECT
.Employee_First_Name, {Table].EMployee_Surname" _
& "FROM Table " _
& "WHERE
.Employee_ID = " & me!Employee_ID_Box.value & ";"

set rst=dbs.openrecordset(strSQL,4)

select case rst.recordcount
CASE IS >1
msgbox (" You have more than 1 employee with this number please go check it etc", "OOPS")
me.Employee_ID_Box.setfocus
CASE IS =1
let me!My_Name_Box.value= rst.fields(0).value & chr(32) & rst.fields(1).value
CASE ELSE
MsgBox("no Records found for this ID, please check blah blah", "NOPE")
me.Employee_ID_Box.setfocus
end select
end sub

you may want some error handling in there as well but this should pretty much work
 
R

rintaro

Guest
thanks for the reply, KDg. i actually understood what you posted, so i guess i'm not _that_ much of a rookie! i'm afraid i didn't make my question very clear, however.
once again, i have a table with productivity data and a table with employee names. what i'm actually trying to create is a form where the clerk can input productivity info which will be appended to the productivity table. the main reason i want the emp name to show up is really just so that the clerk can see that they're inputting for the correct person, but also to ensure consistency in the employees names.
the real hard part for me is figuring out how to get the info into the productivity table once she's entered it. we're really only talking about 5 fields: EmpNum, Function, Date, Units, and Hours. once she inputs these 5 fields and hits <Enter>, how do i get the info to append to the productivity table? and once again, thanks. your post gave me some ideas about other things.
 

Users who are viewing this thread

Top Bottom