three loops for frequency asignment

alpertunga65

Registered User.
Local time
Today, 17:09
Joined
Mar 15, 2013
Messages
21
Hello everybody,

I am trying to build a database to assign specific frequencies to radionets.

And I am able to assing one frequency to one radionet by clicking a button each time. I have solved this problem.

But the second step for me is; assinging frequencies to all radionets at once. SO, I will try to explain what I want to do below;

For frequency assignment;
I have two forms named as "TLSCVR_OTOFREATA" and "OtomatikFrekansAtama"

"TLSCVR_OTOFREATA" is a main form which has radionet subform named TLSCVR_AltformOTO

TLSCVR_AltformOTO has fields OTOCVRID, TEMASFRE, ESASFRE AND YEDEKFRE. OTOCVRID field refers autonumber of radionet. Others are frequency fields.


"OtomatikFrekansAtama" is another form on which I am assigning frequencies. This form based on the frequency list.

When I open "TLSCVR_OTOFREATA" form, it shows all radionets in the subform “TLSCVR_AltformOTO“.
First I am selecting a frequency block (A, B, C etc.) in a combobox then clicking a buton, opening "OtomatikFrekansAtama" form with the selected block name as A, B, or C.

Clicking the buton “Command20;
1. It should select the first radionet, Then;
it will assing “TEMAS” then “ESAS” and “YEDEK” frequencies fort the first radionet. (3 frequencies for each radionet.) (“TEMAS”, “ESAS” and “YEDEK” field are taking values from FREKANSs field as you will see from the Picture of "OtomatikFrekansAtama")
2. Then it should turn to the second radionet and do the same procedures as the first one.
3. This procedure should continue until the last radionet.
4. The problems are here;
a. radionet number maybe more than frequency number (i.e. 150 radionets and 100 frequencies). Then loop must turn to the first frequency again. So I mean it must continue until the last radionet.
b. For the loopI do not want to write a specific number fort he last number of radionet. As 100 or other. I want the loop to identfy the last radio net number during the loop. So in code I wrote it as “For OTOCVRSAY = 1 To DLast(OTOCVRSAY) Step 1”


for a buton (Command20). But it is not working...

Here is my code for the button (Command20) which is not workingJ));

Private Sub Command20_Click()
Dim TEMAS, ESAS, YEDEK, ILKF, SONF, FREDEGER As Double
Dim OTOCVRSAY As Integer

Forms![TLSCVR_OTOFREATA]![TLSCVR_AltformOTO].[Form]![TEMASFRE] = TEMAS
Forms![TLSCVR_OTOFREATA]![TLSCVR_AltformOTO].[Form]![ESASFRE] = ESAS
Forms![TLSCVR_OTOFREATA]![TLSCVR_AltformOTO].[Form]![YEDEKFRE] = YEDEK
BLOKALTFRE = ILKF
BLOKUSTFRE = SONF
Forms![TLSCVR_OTOFREATA]![TLSCVR_AltformOTO].[Form]![CVRID] = OTOCVRSAY
Forms![TLSCVR_OTOFREATA]![TLSCVR_AltformOTO].[Form]![VERICIYERI] = YER
BLOKAD = BLOKAD.Value

For OTOCVRSAY = 1 To DLast(OTOCVRSAY) Step 1
FREKANSs.Value = FREDEGER
For FREDEGER = BLOKALTFRE.Value To BLOKUSTFRE.Value
TEMAS = FREDEGER
Forms![TLSCVR_OTOFREATA]![TLSCVR_AltformOTO].[Form]![FREKODT] = FREKODURET(Len(j - 1))
Next FREDEGER
ESAS = FREDEGER
Forms![TLSCVR_OTOFREATA]![TLSCVR_AltformOTO].[Form]![ESASFREKOD] = FREKODURET(Len(j - 1))
Next FREDEGER
YEDEK = FREDEGER
Forms![TLSCVR_OTOFREATA]![TLSCVR_AltformOTO].[Form]![YEDEKFREKOD] = FREKODURET(Len(j - 1))
Next FREDEGER
Next OTOFRESAY

End Sub

I need HELPPPPP!!!!
I am adding pictures of as "TLSCVR_OTOFREATA" and "OtomatikFrekansAtama"

Thanks
 

Attachments

  • OtomatikFrekansAtama.jpg
    OtomatikFrekansAtama.jpg
    68.6 KB · Views: 97
  • TLSCVR_OTOFREATA.jpg
    TLSCVR_OTOFREATA.jpg
    105.7 KB · Views: 94
1. You've made quite an effort to present your problem. Because of language it is still difficult to wrap one's mind around it. I'd suggest that you remove everything that has no bearing on your problem and translate the remainder of the variables into English.

2. There is much too much text - show relevant tables with English names please.

3. Forget what you do on your forms and which buttons you click on - that makes it even harder to understand and is irrelevant for the solution. Describe the steps necessary to derive the desired result form the data that you have, using English field names.

4. From what I understand you need is a loop to assign x frequencies to y radionets, where x <= y. Is that so?

5. Frequency block is not the same as frequency, is it? Be very very careful what you write - we only have your writings to go on.

6. Where specifically are you stuck? "Not working" contains 0 information. Read my signature

7. Use code tags for code. Edit>Go advanced>select code>press #

8. DLast can give surprising results. Also your syntax for that function is not correct - the correct syntax for it, as for all other Access functions, is in the Access help file or google

Read the items carefully and react to all except 8.
 
In addition to spikepl comments, I would like to add the following:-
1. Avoid using names for buttons as Command20 etc. Use a more meaningful name like assign_frequencies this will save time when trying to debug code. You may know what Command20 does now but will you know what it means say next month.

2. Regarding item 3 in the previous message after describing the steps, break each step into smaller steps using flowchart or pseudo code until there are no more steps. Then do a desk check of the flow chart or psuedo code by stepping through each step using the relevant values.

3. In your code the DIM statements assigns variables, now on the line after the DIM statements you are assigning the variable TEMAS to the TEMASFRE field on the subform. The problem is WHAT VALUE is TEMAS as you have not assigned a value to it. BUT, later in the code you have TEMAS= FREDEGER and this not used at all in the remaining lines of code. This is the same for the other variables ESAS, YEDEK etc.

4. Your line of code For OTOCVRSAY = 1 To DLast(OTOCVRSAY) Step 1
is incorrect you need to DIM another Double or Integer variable e.g temp_counter depending on the maximum size of OTOCVRSAY. Then this line of code would be FOR temp_counter = 1 to OTOCVRSAY then later in your code you will have Next temp_counter

5. Finally, you have Next OTOFRESAY but there is no For OTOFRESAY= x to y in earlier lines of code.
 

Users who are viewing this thread

Back
Top Bottom