how to populate a field in a table based on a conditional statemen

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, and thanks for reading my question.

I have a table of server names, along with much, much more information. I
have added a field called "fqdn." This signifies the fully qualified domain
name of a server. The only thing I need to do is set up a conditional
statement telling Access

that if: the server is in this domain, append this string,
".tac.ads.navy.gov." and add the resulting string to the "fqdn" field for
that entry,
else if: the server is in this domain, append this string,
".tic.ads.navy.gov." and add the resulting string to the "fqdn" field for
that entry, ect....

I don't know if this is doable or not. I have experience with Java and C++
programming, just not VBS or SQL.

Can I do this? Where would I enter this code and what would it look like?

Thanks so much in advance.

-Blenvid
 
There are several ways to do it, but the best way is to not do it!!!
What I mean is, since the fqdn is univocally determined on the basis of
another field that is already stored in your servers table, you should
not store this in the same table, or you'll be unnecessarily duplicating
data in that table, in breach of the fundamental data normalization rules.
The way to do it is to add a new table to your database, with two fields
(unless you already have a omains table): Domain (PK, linked to the
domain field in the servers table), and the "string" (whatever that is).
This way, whenever you need the concatenated string, you look it up by
joining the two tables in a query, or by means of a DLookup function.

HTH,
Nikos
 
Hi Nikos,

Thanks for your quick reply. I understand what you're saying. My employer is
requesting that the fqdn be listed in my server table.

I have a table for my domains. (tbl_Domains) It is linked to the server
table with a one-to-many relationship.

Would you please continue explaining how to accomplish my goal with a query
or DLookup function?

Thank you.

-Blenvid
 
A. Your employer seems to be the kind of know-it-all almost ignorant...
but not completely ignorant, therefore dangerous. I know it's hard to
ignore bad advice coming from your boss, but it's worth the effort to
talk him out of it.

B. Don't be impatient! Your problem may be important to you, but so does
everyone else's to them. Please have a look at:

http://www.mvps.org/access/netiquette.htm

Now, to your question:

DLookup is a function which returns a particular field from a record in
a table (or query), based on a criterion (or multiple criteria). For
instance, a DLookup expression could look something like:
MyString = DLookup("MyStringField", "tbl_Domains", "DomainID=" & _
DomainID)
(syntax can vary depending on whether DomainID is numeric or string;
example above assumes numeric).
Look it up in Access help.

In a query, you would combine the servers table and the domains table;
in a proper design, those would have a relationship on DomainID, so they
would be joined automatically in the query design, otherwise join them
manually. This way, selecting the string field from the domains table
would return the respective string next in each server's record.

HTH,
Nikos
 
Hi Nikos,

I don't know what I said which necessitated the flaming of my employer.

Secondly, I'd appreciate you not make exclamations at me unless you are
certain what is going on. My supposed impatience was in fact a request from
other users/professionals for second opinions.

Third, I have been made unwelcome here by your condescending tone.

Thank you for your assistance in whatever form that may have given. As you
noted in your response, I'll just have to do what I've been doing all along,
"Look it up in Access help."

-Blenvid
 
Blenvid,

I'm sorry if my comments were not clear enough and got misinterpreted, I
never meant to make you feel unwelcome (I don't own the NG's, after
all!), I was just trying to bring to your attention the guidelines that
apply.

Now, if I came out strong on your employer, that was intentional, it's
because I've seen this happen time and again, and was aiming to make you
try to "kill it while it's young". The thing is, if you compromise your
data design (for whatever reason), things are bound to get very tough
further down your development.

Finally, I'll try to remember your name and not answer any of your
future posts, if that makes you uncomfortable, but please don't give up
on the newsgroups on my account; they are a valuable resource, and
you'll soon have no doubt about that.

Regards,
Nikos
 
Back
Top