data input

ngeng4

Registered User.
Local time
Tomorrow, 06:45
Joined
Feb 24, 2010
Messages
47
hi all,
i have a project status n completed year in my form. i want the completed year only appear if the status is completed. i mean if the user enter the completed status, then the msg box or anything will appear ask for the completed year. and these thing both will b save in the database.

so how can i do this?
 
Best you use a text box for input instead, not an input box function. Also my advice would be to change the Enabled property instead of the Visible property. Here's a "sketch":
Code:
If IsNull([COLOR=Black]ProjectStatus.text[/COLOR]) or [COLOR=Black](ProjectStatus.text & "") = ""[/COLOR] Then
     Completed.enabled = false
Else
     Completed.enabled = True
End If
You would put this on the Change event of the control (i.e. ProjectStatus).
 
First up welcome to the forum.

If you are using a check box to indicate that the status is Complete you could use the following code in the Check box's On Click event;

Code:
If Me.CheckBoxName = -1 Then [COLOR="SeaGreen"]'A checked check box will return a value of -1 and uncheck 0[/COLOR]
     Me.CompletedDate.Visible = True
     MsgBox "Please enter a Completed date"
     Me.CompletedDate.SetFocus
Else
     Me.CompletedDate.Visible = False
End If

You would also need the following code in the form's On Current event to show or hide you completed date field as appropriate;
Code:
If Me.CheckBoxName = -1 Then [COLOR="SeaGreen"]'A checked check box will return a value of -1 and uncheck 0[/COLOR]
     Me.CompletedDate.Visible = True
Else
     Me.CompletedDate.Visible = False
End If

If you are not using a check box but rather some other control to indicate Completed status just change the logical test (If statement) to suit the type of data in that particular control.
 
Sounds like you could be breaching normalization. Would not the presence of a date in the CompletedYear be the same as indicating the status as completed?

Just have a bound textbox to enter the CompletedYear. An empty box means "not completed".

You could have the checkbox on the form but it should not be in the table. VBA code could be used to interact the checkbox state with the visibility of the textbox.
 
Based on the comments made by vbaInet and Galaxiom here's a small DB to demonstrate their points. Check out the form's On Current event and the check box's On Click event.
 

Attachments

hmm, again a question.. sorry..:(

if i want to the date through a message box then how?
 
hmm, again a question.. sorry..:(

if i want to the date through a message box then how?

It seems you have not really understood what has already been posted.
Also appears that you haven't downloaded John's example (It still shows zero views).

Difficulty with using a bound textbox = 1
Difficulty with using a messagebox = 6

Difference in benefits by choosing the hard way = 0
 
thank you so much.. i already understand..=)
 

Users who are viewing this thread

Back
Top Bottom