View Full Version : If statement


Craiglowdon
01-25-2008, 05:10 AM
Hi,

i want to create a button which does not allow a user to proceed if a field does not much with the primary key in another table (asking them to enter a correct entry in the field).

I then want the button to oepn a new form and not save the details from the previous form unless all of the second form is entered correctly too. (as the second table is linked to the first by a customer number)

any help appreciated!!

(i need to start putting something back into this board so far im take take take) mental note made to try to help people with anything i can solve!!

Dennisk
01-25-2008, 05:41 AM
you need something like this in the on click event for the button

If isnull(YourControlname) then
msgbox "Yor message here"
else
Open the Form here
Endif

Craiglowdon
01-25-2008, 06:03 AM
Hi, Thanks for your reply but i dont quite understand

the field can contain something but i need it to contain specirfic data from another table.

EG my table has

postcode district
B1
B2
B3
B4

so if B5 is entered into the table it does not find it in the relationship and so does not allow it to be input

Brianwarnock
01-25-2008, 06:29 AM
All data entry should be via forms not directly into tables, the form could then have a dropdown list created from the entries in the other table thus the user would only be able to enter the correct data.

Brian

Craiglowdon
01-25-2008, 06:43 AM
Yes but the data is not inputted by the user at all (not directly) the postcode district data is added via the user entering a postcode and the function running to source the postcode district.

Im thinking that would still enforce integrity though so that is fine.

where do I define the function as a control source???

Sorry Brian i am a pain but i assure you once i understand its in my head forever :) and i will pass on what i know as you are doing now!

Brianwarnock
01-25-2008, 06:56 AM
Herein lies a problem, I had assumed the use of Forms, a form uses the table as a recordsource, and each control on the form has, in its properties a control source, if the control is talking to the table its control source is the entry in the table, else it can be other things, I'm worried that I may have misunderstood some of your requirements and may have occasionally pointed you in the wrong direction.

If the answer is only required on the form then you can put the formula in the control source as previuosly mentioned, if it is required to update the table then place the formula in say the afterupdate event of postcode.

If not using forms I don't know.

Brian

Craiglowdon
01-25-2008, 07:04 AM
Hi Brian,

Sorry I did know about the control source after all as i see this on the forms I have created, I do in fact want the value of the postcode district in the table so im guessing i cant use the form control source to put my function in (which is a shame!) so after update of postcode entry I need to use the function and place into the table??

confusing!

Brianwarnock
01-25-2008, 07:13 AM
Not really.
To save tying I'll abbreviate
In your table you have Pcdistrict, in your form you have a txtPcdistrict control , well if you use the wizard it will be just Pcdistrict , but to simplify my explanation we will leave the txt in for the form fields,with contol source Pcdistrict

In the afterupdate of txtPostcode you code your subroutine, the one with the Split etc and me.txtPcdistrict = array(0), the table Pcdistrict will be automatically updated as the form and table indulge in a 2 way dialogue.

Brian

Craiglowdon
01-25-2008, 08:15 AM
Ahhhh you explained that in a way that a monkey could understand !! thank you very much ( i need that sometimes)

Brian you are a gentlemen! many thanks once again