Hello everyone, Can you please tell me how to make a field a function of another field in VB6 using access database?
I didn't get you. can you make it more clear?
??
I am working on a hotel database. I have two fields, one room number and the other room class. I want the field room class be a function of room number. For example for the rooms between 1 & 20, it'd be C; for 21 to 40 it's be B and for 41 to 60 it'd be A. Any idea how can I do that?
You can write a code in your program to do this. In your input form, if someone inputs the room number set the values A,B,C according to the condition to a another text field automatically. Also disable the textbox so that no one can edit the automatically assigned value. Save the texts in database as usual. For example. write the if statements inside the module Private Sub Text1_Change() .......................... ........................ <if statements here like below> if val(text1.text)>=1 and val(text1.text)<=40 then text2.text="A" ....................... ......................... End Sub I hope that this will help you or at least provide a hint.
Actually I entered the values manually using Access. But I found that I have to use ADODB in order to make a field a function of another field. For example: Dim RS as New ADODB.Recordset RS!Age= Year(Date) - Year(RS!Birthdate) Thanks for your reply btw! :)
Join our real-time social learning platform and learn together with your friends!