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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter 3 records

Status
Not open for further replies.

chefboy

IS-IT--Management
Jan 2, 2002
34
US
I am not sure exactly what I need to do here in this senerio. Please advise.

In Access I have a form that needs to have different data in one of the fields dependant on a 3rd field. I just might need an IF then statement, but I am not sure. I want to keep it as simple as possible.

If NewDocumentChange is true then Populate the field with the NewDocument Else Populate the field with the OldDocument.

How do I make this work with one field.
 
Write your if then code on the afterupdate event for the third field.
 
What exactly would the statement look like?
 
sub NewDocumentChange_AfterUpdate()

if newdocumentchange then
field=Newdocument
else
field =Olddocument
end if
end sub
 
I am still having problems. Here Is the code I inserted into VB

Sub DocumentNumberChange_AfterUpdate()

If DocumentNumberChange Then #This is a Checkbox
Field = NewDocumentNumber
Else
Field = DocumentNumber
End If

End Sub

The textbox gives -1 for the answer

Is there something else I am missing. Thank you for your help this far.
 
What type of field is Field (text, number, date, etc), and what types of fields are NewDocumentNumber and DocumentNumber?
 
DocumentNumberChange # YES/NO
NewDocumentNumber # Text field
DocumentNumber # Text field

Am I supposed to have anything in the "Control source"?
 
Maybe we have to be more specific.

With Me 'refers to the form you are on
If .DocumentNumberChange Then 'This is a Checkbox
.Field = !NewDocumentNumber
Else
.Field= !DocumentNumber
End If
End with
End Sub

This is saying that documentnumber and newdocumentnumber are values in the underlying control source for the form, and you are taking the values that it is opened with. Field is a textbox on the form, and DocumentNumberChange is a checkbox on the form. If you want documentnumber and newdocument number to be textboxes instead of just the values of the underlying data source, just put a . in front instead of the !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top