Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple forms question

Status
Not open for further replies.

mrwendell

Programmer
Aug 22, 2003
43
US
i have a input form that ask for [ssn] if the ssn is invalid i have a msgbox vbok...here it stops execution and shows input form again...with the previous entry still there and hilighted...what i want is an empty textbox with focus of course? can anyone help please.

ok one more...plz

2 forms....(1) mainform and (1) subform(datasheet)...this is a timecard form entries are made on the subform either using cbo or txtbox...user must input a weekending date on each new entry because i cannot figure out how to put a cboWEDATES on the main form and have the subform populate each new entry on the subform weekending field....

if i can accomplish this last task...i think i will have an application that is completely user friendly.

anyone out there want to help me get some brownie points...lol...thanks.
 
try this:

after the msgbox code insert the following:

textboxname.value = ""
textboxname.setfocus

for the second question, on your Main form insert a textbox for WEDate (i.e. call it MainFormWETextbox). also, if you haven't already, create another textbox for WEDate and include it on the subform (i.e. call it SubformWETextbox)

then in the subform, in the On Current property event insert the following code:

SubformWETextbox.value = Forms!NameofMainForm!MainFormWETextbox.value

hope this helps you.

 
Mr Wendell,

For number 1 it seems like you already have some VBA code that gives them the error msg and then goes back to your input form. What you want is for the [SSN] field to be blank when you go back. Under the code for the msgbox I would add.

Me.SSN = Null
DoCmd.GoToControl "SSN"

***************************
For Question number 2. Here is what I would do. Please replace MainForm and SubForm with the actual names of your forms.

On the subforms On Before Insert event place the following code:

' Check to make sure cboWeekending is filled out
If IsNull(Forms!mainform!cboweekending) Then
Exit Sub
End If
' Get the value from the cboweekending Combobox
Me.Weekending = Forms!Mainform.cboweekending


What this code does is checks for a value on the mainform, and if there is a value enters that value on the subform. If there is no value on the main form it exits the function.

There might be an easier way to do this and other people might call me on it!

Chris
 
CGHoga,

Be careful with the On Current as that code will replace the date if a user goes back into a record to view it. Not sure if that will happen in that database but that is why I used the On Before Insert event.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top